[英]kendo ui grid row filterable wont filter an complex object
iam trying to row filter the column Mid which is an complex object containg two properties { Id: 0, Name: "Select MID" }我正在尝试对列 Mid 进行行过滤,该列是一个包含两个属性的复杂对象 { Id: 0, Name: "Select MID" }
now when i type some value in the filter input iam gettig this exeption现在,当我在过滤器输入中输入一些值时,我会得到这个例外
VM1033:3 Uncaught TypeError: (d.Mid || "").toLowerCase is not a function VM1033:3 Uncaught TypeError: (d.Mid || "").toLowerCase 不是函数
iam geussing this is because Mid is an object and not a premetive type我猜这是因为 Mid 是一个对象而不是一个 premetive 类型
any ideas ?有任何想法吗 ?
thank u感谢你
this is my grid:这是我的网格:
$("#grid_1").kendoGrid({
dataSource: {
dataType: "d",
transport: {
read: {
url: crudServiceBaseUrl + "/Read",
},
update: {
url: crudServiceBaseUrl + "/Update",
type: "post",
contentType: "application/json; charset=utf-8",
complete: function (e) {
jQuery("#load_balancer_grid").data("kendoGrid").dataSource.read();
}
},
create: {
url: crudServiceBaseUrl + "/Create",
type: "post",
contentType: "application/json; charset=utf-8",
complete: function (e) {
jQuery("#load_balancer_grid").data("kendoGrid").dataSource.read();
}
},
destroy: {
url: crudServiceBaseUrl + "/Delete",
dataType: "d"
},
parameterMap: function (options, operation) {
}
},
batch: true,
pageSize: 100,
schema: {
model: {
id: "MidGroupId",
fields: {
MidGroupId: { validation: { required: true }, editable: true, type: "number" },
Mid: { validation: { required: true }, editable: true, defaultValue: { Id: 0, Name: "Select MID" } },
RouteSales: {
type: "boolean",
parse: function (value) {
if (value != null) {
return value || false;
}
return value;
},
nullable: true
},
RouteRebills: { type: "boolean" },
QueueRebills: { type: "boolean" },
// ResetCounters: { type: "boolean" },
}
}
}
},
sortable: true,
batch: true,
groupable: true,
pageable: {
refresh: true,
pageSizes: true,
buttonCount: 5
},
filterable: {
mode: "row"
},
toolbar: kendo.template($("#template").html()),
edit: function(e) {
if (e.model.isNew() == false) {
$(e.container.find("input[name=MidGroupId]")).attr('disabled', 'disabled');
$(e.container.find("input[name=Mid]")).attr('disabled', 'disabled');
$(e.container.find("input[name=CardType]")).attr('disabled', 'disabled');
}
},
columns: [
{
field: "MidGroupId", type: "number"
},
{
field: "Mid", editor: MidDropDownEditor, template: "#=Mid.Name#", title: "MID",
filterable: {
cell: {
dataSource: {
type: "d",
transport: {
read: crudServiceBaseUrl + "/GetMidsOptions"
}
}
,
dataValueField: "Id",
dataTextField: "Name"
}
}
}
],
editable: true
});
iam trying to filter a an object我试图过滤一个对象
PerdataSource API there is no dataType property directly on the dataSource, so below part is not correct, so this might be reason for your error:每个数据源 API没有直接在数据源上的 dataType 属性,因此以下部分不正确,因此这可能是您出错的原因:
dataSource: {
dataType: "d",
dataType can be defined deeper inside transport CRUD of the dataSource transport, as you already have it there. dataType 可以在 dataSource 传输的传输 CRUD 内部更深地定义,因为您已经在那里有了它。 I have not tried putting a complex object to grid column, why not to do it on the server?我没有试过把复杂的对象放到网格列中,为什么不在服务器上做呢? it would be most natural to create a primitive property on a server and just use it easily in the grid.在服务器上创建原始属性并在网格中轻松使用它是最自然的。
I ran into this problem too.我也遇到了这个问题。 The solution is updating model.dirtyFilds in the editor when the change handler fires.解决方案是在更改处理程序触发时更新编辑器中的 model.dirtyFilds。 It looks like:看起来像:
function MidDropDownEditor(container, options){
$(`<input id="MidEditor" name="Mid" data-bind="value:Mid" />`)
.appendTo(container)
.kendoDropDownList({
autoBind: false,
filter: "startswith",
dataTextField: "Name",
dataValueField: "Id",
enable: false,
change: function(){
if (options.model.dirtyFields['Mid']) {
options.model.dirtyFields['Mid.Name'] = true;
}
}
});
In column setting you should set property 'field' like "Mid.Name".在列设置中,您应该设置属性“字段”,如“Mid.Name”。
It works for me.这个对我有用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.