简体   繁体   English

Kendo Grid复选框,布尔值无效

[英]Kendo Grid checkbox with boolean values not working

I have a field that is a boolean but grid doesn't fetch the value (0 or 1) correctly and doesn't update properly if changed. 我有一个布尔字段但网格没有正确获取值(0或1),如果更改则不能正确更新。 It also doesn't show checked using a template if the field (enabled) is 1. 如果字段(已启用)为1,则也不会使用模板进行检查。

But, if I set the field type to string instead of boolean, it all works as expected, but you have to type in 0 or 1 which is not what I want: 但是,如果我将字段类型设置为字符串而不是布尔值,它将按预期工作,但您必须键入0或1,这不是我想要的:

{
    field: "enabled",
    template: '<input type="checkbox" #= enabled == "1" ? checked="checked" : "" # />',
    width: 50,
    title: "Enabled"
}

If I use the template on the field as a boolean, all check boxes are blank as if "enabled" is always null, which it is not. 如果我在字段上使用模板作为布尔值,则所有复选框都为空,就好像“enabled”始终为null,而不是。

Example data coming from the server: 来自服务器的示例数据:

{"data":[{"id":"57","username":"adf@saddf.com","type":"1","level":"1","firstName":"asdf","middleName":"","lastName":"asdf","DoB":"0000-00-00","dateStarted":"0000-00-00","enabled":"1"}], "rowcount": 4}

How can I get this to work properly? 我怎样才能让它正常工作?

I figured it out. 我想到了。

Returned booleans must be in the form of literally "true" or "false", not 1 or 0. 返回的布尔值必须是字面上的“真”或“假”,而不是1或0。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM