은 (그리드의 첫 번째 행의 내용을 확인 충분한가요 그렇다면, 당신은으로 열을 숨 깁니다 dataBound
핸들러 정의 할 수 있습니다 :
이
dataBound : function (e) {
// Get reference to the grid
var grid = e.sender;
// Get reference to received data
var data = e.sender.dataSource.data();
// Check that we actually received any data
if (data.length > 0) {
// Iterate on columns hiding those that in the first row have no data
$.each(grid.options.columns, function (idx, elem) {
if (!data[0][elem.field]) {
grid.hideColumn(idx);
}
});
}
}
이 언제 실행을 서버에서 데이터를 수신했지만 앞에서 말했듯이 첫 번째 내용 만 검사하지만 모두 확인하기 위해 쉽게 수정할 수 있습니다.이 기능은 구현되지 않은 메뉴에서 열 제목을 숨기는 것입니다.
여기에있는 예 : http://jsfiddle.net/OnaBai/XNcmt/67/
EDIT : 데이터가없는 열은 표시되지 않지만 메뉴에도 표시되지 않도록하려면 열이없는 표에 columns
을 구성해야합니다.
// Fetch data from the DataSource
ds.fetch(function (d) {
// By default, no column in the grid
var columns = [];
// List of available column definitions
var definitions = [
{ field: "Id", hidden: true },
{ field: "FirstName", title: "First Name" },
{ field: "LastName", title: "Last Name" },
{ field: "City" },
{ field: "Position" }
];
// For each column in the definition check if there is data
$.each(definitions, function(idx, elem) {
if(d.items[0][elem.field]) {
// If there is data then copy the definition to columns
columns.push(elem);
}
});
// Use received data plus the columns definition computed
$("#grid").kendoGrid({
dataSource: d.items,
editable : false,
pageable : true,
columnMenu: true,
columns : columns
}).data("kendoGrid");
});
ds
가 DataSource
정의입니다 : 데이터가 같은 일을하고 수신 후에는 런타임에 그것을 할 수 있습니다.
여기를 참고하십시오 :
안녕하세요. – SantyEssac