如何从剑道网格表格标题中删除文本?

问题描述 投票:0回答:2

我正在尝试删除我的Kendo网格中的标题文本,但是如果将标题保留为空白,则会显示字段名称,并且对于第一列,我需要删除该文本,因为它不需要在那里

$(document).ready(function() {

  LoadValidationResults();
});
var ds = [{
    Severity: 1,
    RoomName: "Main",
    CatalogName: "Bens",
    Area: "Front",
    Context: "Global",
    AlertMessage: "Test Message 11111111111111111111111111111111"
  },
  {
    Severity: 2,
    RoomName: "Main",
    CatalogName: "Georges",
    Area: "Upper",
    Context: "Item",
    AlertMessage: "Test Message 2"
  },
  {
    Severity: 3,
    RoomName: "Main",
    CatalogName: "Marys",
    Area: "Lower",
    Context: "Global",
    AlertMessage: "Test Message 3"
  },
  {
    Severity: 4,
    RoomName: "Main",
    CatalogName: "Julie",
    Area: "Back",
    Context: "Item",
    AlertMessage: "Test Message 4"
  },
];

function LoadValidationResults() {
  $('#ValidationResultsGrid').empty();
  $('#ValidationErrorText').empty();

  $("#ValidationResultsGrid").kendoGrid({
    dataSource: {
      data: ds
    },
    schema: {
      model: {
        fields: {
          RoomName: {
            type: "string"
          },
          AreaName: {
            type: "string"
          },
          CatalogName: {
            type: "string"
          },
          CatalogVersion: {
            type: "string"
          },
          CatalogSection: {
            type: "string"
          },
          Context: {
            type: "string"
          },
          GlobalGroupName: {
            type: "string"
          },
          Row: {
            type: "number"
          },
          ItemRowNum: {
            type: "string"
          },
          Severity: {
            type: "number"
          },
          AlertMessage: {
            type: "string"
          },
          ValidateRuleID: {
            type: "number"
          }
        }
      }
    },
    filterable: false,
    columns: [{
        field: "Severity",
        title: "",
        //template: "#= ValidationResultSeverityLevel(Severity) #",
        width: "50px"
      },
      {
        field: "RoomName",
        title: "Room",
        hidden: false
      },
      {
        field: "CatalogName",
        title: "Catalog",
        hidden: false
      },
      {
        field: "Area",
        title: "Area"
      },
      {
        field: "Context",
        title: "Context",
      },
      {
        field: "AlertMessage",
        title: "Validation Alert",
        attributes: {
          style: "overflow: hidden !important;text-overflow: ellipsis;white-space: nowrap;",
        }
      }
    ],
    scrollable: true,
    selectable: "row",
    dataBound: function() {},
    change: function(e) {},
    height: "192px"
  });
}
<link rel="stylesheet" href="https://kendo.cdn.telerik.com/2020.2.513/styles/kendo.default-v2.min.css" />
<script src="https://kendo.cdn.telerik.com/2020.2.513/js/jquery.min.js"></script>
<script src="https://kendo.cdn.telerik.com/2020.2.513/js/kendo.all.min.js"></script>


<div id="ValidationResultsGrid"></div>
jquery kendo-ui kendo-grid
2个回答
0
投票

我知道了

$('#ValidationResultsGrid table th')[0].innerHTML = "";

0
投票

空字符串将不起作用,但一个空格" "将起作用:

...
columns: [{
        field: "Severity",
        title: " ",
        //template: "#= ValidationResultSeverityLevel(Severity) #",
        width: "50px"
      },
...

$(document).ready(function() {

  LoadValidationResults();
});
var ds = [{
    Severity: 1,
    RoomName: "Main",
    CatalogName: "Bens",
    Area: "Front",
    Context: "Global",
    AlertMessage: "Test Message 11111111111111111111111111111111"
  },
  {
    Severity: 2,
    RoomName: "Main",
    CatalogName: "Georges",
    Area: "Upper",
    Context: "Item",
    AlertMessage: "Test Message 2"
  },
  {
    Severity: 3,
    RoomName: "Main",
    CatalogName: "Marys",
    Area: "Lower",
    Context: "Global",
    AlertMessage: "Test Message 3"
  },
  {
    Severity: 4,
    RoomName: "Main",
    CatalogName: "Julie",
    Area: "Back",
    Context: "Item",
    AlertMessage: "Test Message 4"
  },
];

function LoadValidationResults() {
  $('#ValidationResultsGrid').empty();
  $('#ValidationErrorText').empty();

  $("#ValidationResultsGrid").kendoGrid({
    dataSource: {
      data: ds
    },
    schema: {
      model: {
        fields: {
          RoomName: {
            type: "string"
          },
          AreaName: {
            type: "string"
          },
          CatalogName: {
            type: "string"
          },
          CatalogVersion: {
            type: "string"
          },
          CatalogSection: {
            type: "string"
          },
          Context: {
            type: "string"
          },
          GlobalGroupName: {
            type: "string"
          },
          Row: {
            type: "number"
          },
          ItemRowNum: {
            type: "string"
          },
          Severity: {
            type: "number"
          },
          AlertMessage: {
            type: "string"
          },
          ValidateRuleID: {
            type: "number"
          }
        }
      }
    },
    filterable: false,
    columns: [{
        field: "Severity",
        title: " ",
        //template: "#= ValidationResultSeverityLevel(Severity) #",
        width: "50px"
      },
      {
        field: "RoomName",
        title: "Room",
        hidden: false
      },
      {
        field: "CatalogName",
        title: "Catalog",
        hidden: false
      },
      {
        field: "Area",
        title: "Area"
      },
      {
        field: "Context",
        title: "Context",
      },
      {
        field: "AlertMessage",
        title: "Validation Alert",
        attributes: {
          style: "overflow: hidden !important;text-overflow: ellipsis;white-space: nowrap;",
        }
      }
    ],
    scrollable: true,
    selectable: "row",
    dataBound: function() {},
    change: function(e) {},
    height: "192px"
  });
}
<link rel="stylesheet" href="https://kendo.cdn.telerik.com/2020.2.513/styles/kendo.default-v2.min.css" />
<script src="https://kendo.cdn.telerik.com/2020.2.513/js/jquery.min.js"></script>
<script src="https://kendo.cdn.telerik.com/2020.2.513/js/kendo.all.min.js"></script>


<div id="ValidationResultsGrid"></div>
© www.soinside.com 2019 - 2024. All rights reserved.