简体   繁体   English

Kendo TreeList绑定不会在行上持续存在

[英]Kendo TreeList Bindings Do Not Persist On Row Edit

I have a treelist and I need icons in the rows, but I also need the rows to be editable. 我有一个树形列表,并且行中需要图标,但是行也需要可编辑。 I have put together an example of a strange error I am getting here. 我整理了一个我到这里的奇怪错误的例子。

http://dojo.telerik.com/OyaB/10 http://dojo.telerik.com/OyaB/10

In the sixth column you can see an icon, it is bound to an event but if you edit the row and update it the binding is lost, so I added a new bind event on save and this causes a very strange error telling me 'Uncaught TypeError: Cannot read property 'unbind' of undefined', which I do not quite understand. 在第六列中,您可以看到一个图标,该图标已绑定到一个事件,但是如果您编辑该行并对其进行更新,则绑定会丢失,因此我在保存时添加了一个新的bind事件,这会导致一个非常奇怪的错误,告诉我“未捕获TypeError:无法读取属性“ unbind”的“ undefined”,我对此不太了解。 Do you guys have any ideas why this is happening or is this just a bug because the tree list is a new feature? 你们有什么想法为什么会发生这种情况,还是因为树形列表是一项新功能而只是一个错误? Thanks in advance. 提前致谢。

since the binding is a click to a function delegate you can try to bind using the on() function from jquery. 由于绑定是对函数委托的单击,因此您可以尝试使用jquery的on()函数进行绑定。

$("#treelist").on('click', 'span#uploadSpec', function () {
     alert("Stuff");
});

I believe then the bind is persisted as it is held by the treelist then when trigger filtered to a particular element in the cell ('span#uploadSpec'). 我相信然后绑定将一直保留,因为它被树列表保留,然后当触发器过滤到单元格中的特定元素时('span#uploadSpec')。

After that you can work around finding the dataitem etc using: 之后,您可以使用以下方法来查找数据项等:

var treelist = $("#treelist").data().kendoTreeList;
var dataItem = treelist.dataItem($(this).closest('tr'));
OpenPdfForEmployeeByEmployeeId(dataItem.EmployeeId);

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

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