如何使用Kendo TreeList parentID和hasChildren的自定义字段(How to use custom fields for Kendo TreeList parentID a

编程入门 行业动态 更新时间:2024-10-28 22:24:40
如何使用Kendo TreeList parentID和hasChildren的自定义字段(How to use custom fields for Kendo TreeList parentID and hasChildren)

我只花了4天时间研究如何做到这一点,因为它不在文档中,我无法得到Telerik的任何支持,即使我是付费客户在此问题上提供支持票。 为了对Telerik公平,我认为这是由于一个非常糟糕的支持技术,它们通常都很好。 Telerik如果您正在阅读门票号码:964961,962272。我们希望下次有更好的回复。

希望这可以节省4天的其他人......这是我遇到的问题以及我如何修复它。

我正在使用Kendo TreeList执行按需加载方案。 我们有自己的请求管理器来处理与服务器的所有事务,因此我们在Kendo dataSource的读传输上使用JS函数,并使用options.success(aData)将从服务器返回的数据放入dataSource。

我们有调用MySQL procs的PHP路由,MySQL将所有内容作为字符串返回,因此当PHP将结果转换为JSON时,所有非空值都将作为字符串发送。 这包括hasChildren字段。

通常这不是问题,因为Kendo dataSource将根据dataSource Schema中定义的类型正确键入值。 但是我发现在将数据分配给dataSource之后,所有hasChildren:“true”,值将转换为hasChildren:false,因此没有展开按钮将显示在TreeList上,用于具有子项的按需加载项。

所以我需要一种方法将hasChildren字段映射到一个类型字段,这样就可以实现从字符串到bool的转换。

这就是我最终的工作:

"OpParent": { "type": "number", "nullable": true }, "parentId": { "type": "number", "field": "OpParent", "defaultValue": null }, "OpHasChildren": { "type": "boolean", "nullable": true }, "hasChildren": { "type": "boolean", "field": "OpHasChildren" }

我还发现,如果您的根级父级的值为null,则需要在parentID定义中将defaultValue设置为null。

希望这可以节省一些人花时间来解决这个问题。

Telerik,请把它放在文档中!!

问候,

斯科特

I just spent 4 days working out how to do this as it is not in the documentation and I could not get any support from Telerik, even though I am a paying customer that lodged support tickets on this issue. To be fair to Telerik I think this was due to one very poor support tech, they are usually pretty good. Telerik if you reading check out ticket numbers: 964961, 962272. Let's hope for a better response next time.

In the hope that this saves someone else 4 days... here is the problem I had and how I fixed it.

I was doing a load on demand scenario with the Kendo TreeList. We have our own request manager that handles all transactions with the server, so we use a JS function on the read transport for the Kendo dataSource, and use options.success(aData), to put the data returned from the server into the dataSource.

We have PHP routes which call MySQL procs, and MySQL returns everything as a string, so when PHP converts the results into JSON, all non null values are sent as strings. This includes the hasChildren field.

Normally this is not a problem as the Kendo dataSource will type the values correctly according to the types defined in the dataSource Schema. However I found that after the data was assigned to the dataSource, all the hasChildren: "true", values would get converted to hasChildren: false and as a result no expand buttons would show on the TreeList for the load on demand items that had children.

So I needed a way to map the hasChildren field to a typed field so the conversion from string to bool would happen.

Here what I finally got to work:

"OpParent": { "type": "number", "nullable": true }, "parentId": { "type": "number", "field": "OpParent", "defaultValue": null }, "OpHasChildren": { "type": "boolean", "nullable": true }, "hasChildren": { "type": "boolean", "field": "OpHasChildren" }

I also found that if your root level parent has a value of null, you need to set the defaultValue to null in the parentID definition.

Hopefully this will save someone the time it took to work this out.

Telerik, please put this in the documentation!!

Regards,

Scott

最满意答案

问题是答案;-)

但对于那些想在答案中看到答案的人来说......这里是:

这就是我最终的工作:

"OpParent": { "type": "number", "nullable": true }, "parentId": { "type": "number", "field": "OpParent", "defaultValue": null }, "OpHasChildren": { "type": "boolean", "nullable": true }, "hasChildren": { "type": "boolean", "field": "OpHasChildren" }

我还发现,如果您的根级父级的值为null,则需要在parentID定义中将defaultValue设置为null。

希望这可以节省一些人花时间来解决这个问题。

The question was the answer ;-)

But for those that want to see the answer in the answer.... here it is:

Here what I finally got to work:

"OpParent": { "type": "number", "nullable": true }, "parentId": { "type": "number", "field": "OpParent", "defaultValue": null }, "OpHasChildren": { "type": "boolean", "nullable": true }, "hasChildren": { "type": "boolean", "field": "OpHasChildren" }

I also found that if your root level parent has a value of null, you need to set the defaultValue to null in the parentID definition.

Hopefully this will save someone the time it took to work this out.

更多推荐

本文发布于:2023-08-04 08:38:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1412255.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:自定义   字段   如何使用   TreeList   Kendo

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!