Kendo ui 剑道分组不起作用
我有一个剑道格网,并在其中启用了分组。问题是有时分组不起作用 它在顶部显示一个带禁用符号的圆圈 下面是我的网格代码:Kendo ui 剑道分组不起作用,kendo-ui,kendo-grid,Kendo Ui,Kendo Grid,我有一个剑道格网,并在其中启用了分组。问题是有时分组不起作用 它在顶部显示一个带禁用符号的圆圈 下面是我的网格代码: $("#divGrid").kendoGrid({ dataSource: { transport: { read: function (options) { var webMethod = "Portal.aspx/DisplayNotes";
$("#divGrid").kendoGrid({
dataSource: {
transport: {
read: function (options) {
var webMethod = "Portal.aspx/DisplayNotes";
$.ajax({
type: "POST",
url: webMethod,
data: displayParams,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (result) {
options.success(result.d);
}
})
}
},
schema: {
model: {
id: "ID",
fields: {
ID: { editable: false, nullable: true },
IsDeleted: { type: "boolean" },
Text: { type: "string" },
CreatedByDisplayName: { type: "string" },
CreatedDateTime: { type: "date" },
Order: { type: "number" },
PermissionType: { type: "string" },
LastEditedByUserGUID: { type: "string" },
GUID: { type: "string", validation: { required: true } },
}
}
},
pageSize: 5
},
dataBound: onDataBound,
batch: true,
edit: function (e) {
// To stop the Auto Refresh of the grid on edit
isEditing = true;
},
groupable: true,
scrollable: true,
sortable: true,
reorderable: true,
toolbar: "<div><img id='imgExportDoc' style='margin-left:15px' onclick='ExportData(1);' title='Export in Word Format' src='images/doc-Icon.png'/><img id='imgExportExcel' onclick='ExportData(2);' style='margin-left:15px' title='Export in Excel Format' src='images/xls-Icon.png'/><img id='imgExportPDF' style='margin-left:15px' onclick='ExportData(3);' title='Export in PDF Format' src='images/pdf_icon.jpg'/></div>",
resizable: true,
selectable: "row",
autoSync: true,
editable: true,// "inline",
navigatable: true,
columnMenu: true,
pageable: {
refresh: true,
pageSizes: true,
buttonCount: 5
},
columns: [
{
field: "ID", width: width0, title: "Note ID", template: function (dataItem) {
if (typeof dataItem.Id != "string") {
return "<a target=\"_blank\" href=\"http://www.google.com\">" + dataItem.ID + "</a>";
} else {
return dataItem.ID;
}
}
},
{ field: "IsDeleted", width: width1, title: "IsDeleted" },
{ field: "Text", title: "Note Text", width: width2 },
{ field: "CreatedDateTime", title: "Created Datetime", width: width3 },
{ field: "Order", title: "Order", width: "140px", width: width4 },
{ field: "PermissionType", title: "Permission Type", width: width5 },
{ field: "LastEditedByUserGUID", title: "Last Edited By", editor: ddlSimpleEditor, width: width6 },
{ command: { text: "Delete", click: deleteNoteData }, title: "Delete", width: width7, menu: false },
{ field: "GUID", hidden: true, title: "Hidden", menu: false, width: width8 }]
, filterable: true,
columnMenu: {
sortable: false
}
});
$(“#divGrid”).kendoGrid({
数据源:{
运输:{
阅读:功能(选项){
var webMethod=“Portal.aspx/DisplayNotes”;
$.ajax({
类型:“POST”,
url:webMethod,
数据:显示参数,
contentType:“应用程序/json;字符集=utf-8”,
数据类型:“json”,
成功:功能(结果){
选择:成功(结果d);
}
})
}
},
模式:{
型号:{
id:“id”,
字段:{
ID:{可编辑:false,可空:true},
IsDeleted:{type:“boolean”},
文本:{type:“string”},
CreatedByDisplayName:{type:“string”},
CreatedDateTime:{type:“date”},
顺序:{type:“number”},
PermissionType:{type:“string”},
LastEditedByUserGUID:{type:“string”},
GUID:{type:“string”,验证:{required:true},
}
}
},
页面大小:5
},
数据绑定:onDataBound,
批次:对,
编辑:功能(e){
//在编辑时停止网格的自动刷新
i编辑=真;
},
分组:对,
可滚动:对,
可排序:是的,
可重定额:对,
工具栏:“”,
可调整大小:正确,
可选:“行”,
自动同步:对,
可编辑:true,/“内联”,
可导航:是的,
专栏菜单:是的,
可分页:{
刷新:是的,
页面大小:对,
按钮数:5
},
栏目:[
{
字段:“ID”,宽度:宽度0,标题:“注释ID”,模板:函数(数据项){
if(dataItem.Id的类型!=“字符串”){
返回“”;
}否则{
返回dataItem.ID;
}
}
},
{字段:“IsDeleted”,宽度:width1,标题:“IsDeleted”},
{字段:“文本”,标题:“注释文本”,宽度:宽度2},
{字段:“CreatedDateTime”,标题:“CreatedDateTime”,宽度:width3},
{字段:“顺序”,标题:“顺序”,宽度:“140px”,宽度:宽度4},
{字段:“权限类型”,标题:“权限类型”,宽度:width5},
{字段:“LastEditedByUserGUID”,标题:“LastEditedByUserGUID”,编辑器:ddlSimpleEditor,宽度:width6},
{命令:{text:“Delete”,单击:deleteNoteData},标题:“Delete”,宽度:width7,菜单:false},
{字段:“GUID”,隐藏:真,标题:“隐藏”,菜单:假,宽度:宽度8}]
,可过滤:正确,
列菜单:{
可排序:false
}
});
可能的原因是什么
还想知道如何动态设置剑道网格的高度。下面是动态高度的代码:
//Below code is for defining the height of the grid
$(".k-grid-content").height('400');
只需参考最新的剑道UI程序集,您的分组问题将被删除。我发现了问题,实际上您在重新绑定网格之前没有正确销毁网格: 以下是正确销毁的代码:
var grid = $("#YourGridName").data("kendoGrid");
if (grid) {
//destroy the previous Grid instance
grid.destroy();
//clean up the html
grid.wrapper.html("");
}
希望这能有所帮助。有时候是什么意思?你能重现它吗,步骤是什么?是的,当我用一组新的结果重新加载网格时会发生什么,那么在这种情况下,我发现了这个问题。谢谢尼廷。高度解决方案非常适合我,但即使参考了最新的组件,我也无法找到分组问题的解决方案。实际上,第一次它工作正常,但当我用新的结果集再次加载网格时,分组就不起作用了。你在重新绑定数据之前是否清除网格,如果是,那么如何?我有一个div,我正在转换为剑道网格,所以我只是将该div的Html清除为$(“#divGrid”).Html(“”)@user3248355尽可能不要
破坏并重新创建网格,这在时间和内存方面是一项昂贵的操作。您可以在不破坏数据的情况下读取新数据。过去最好隐藏网格,然后在读取新数据后再显示出来。@OnaBai上述答案解决了我在重新绑定网格时分组的问题。是的,可能会影响性能,但我的问题由此得到解决。@OnaBai是的,销毁和重新创建在性能方面是一项昂贵的操作,但user3248355正在清除用于销毁网格的div的html,我只是提供了一种销毁网格的正确方法,这也有助于解决分组问题。