简体   繁体   English

Kendo网格:使用jQuery使多个单元格连续变脏

[英]Kendo grid: Make multiple cells dirty in a row using jQuery

I have a batch editable grid. 我有一个可批量编辑的网格。 I modify the dataitems via jQuery, and mark the changed value as dirty like this: grid._modelChange({ field: "propertyName", model: dataItem}); 我通过jQuery修改了数据项,并将更改后的值标记为肮脏,如下所示:grid._modelChange({field:“ propertyName”,model:dataItem}); The other way is the set() method: dataItem.set("propertyName","value"), but I don't use it because is extremely slow. 另一种方法是set()方法:dataItem.set(“ propertyName”,“ value”),但我不使用它,因为它非常慢。

I want to mark multiple cells as dirty in a row, but when I mark the second field, the dirty mark of the first Prop disappears, and when mark the third field as changed, the dirty mark from the second field disappears, so only the third Prop becomes dirty. 我想将多个单元格连续标记为脏,但是当我标记第二个字段时,第一个Prop的脏标记消失了,而当将第三个字段标记为已更改时,第二个字段的脏标记消失了,所以只有第三支柱变脏。

The following loop does the dataItem update and marking the field as dirty: 以下循环执行dataItem更新并将字段标记为脏:

            $(GridDataItems).each(function () {

                        this.Prop1 = false;
                        Grid._modelChange({ field: "Prop1", model: this });

                        this.Prop2 = "someValue";
                        Grid._modelChange({ field: "Prop2", model: this });

                        this.Prop3= "someOtherValue";
                        Grid._modelChange({ field: "Prop3", model: this });                                                
                }
            );

I need something like this: 我需要这样的东西:

Grid._modelChange({ field: "Prop1", model: dataItem },
                  { field: "Prop2", model: dataItem },
                  { field: "Prop3", model: dataItem });

Any ideas for the dirty marks not to disappear? 有什么想法让脏痕不消失吗? Thanks. 谢谢。

I believe this is the correct behavior of a Kendo grid. 我相信这是剑道网格的正确行为。 Check this link out: 检查此链接:

http://www.telerik.com/forums/manually-updating-multiple-values#YfUbqGvY6UePysCKirK08A http://www.telerik.com/forums/manually-updating-multiple-values#YfUbqGvY6UePysCKirK08A

Check the article out, this talks about highlighting multiple cells with dirty flag: 查看文章,这里讨论了用脏标志突出显示多个单元格:

http://blog.codebeastie.com/kendo-grid-javascript-data-manipulation/ http://blog.codebeastie.com/kendo-grid-javascript-data-manipulation/

Thank you everybody, I finally found the solution in this blog post: 谢谢大家,我终于在此博客文章中找到了解决方案:

https://web.archive.org/web/20171227135334/http://blog.codebeastie.com/kendo-grid-javascript-data-manipulation/ https://web.archive.org/web/20171227135334/http://blog.codebeastie.com/kendo-grid-javascript-data-manipulation/

The problem was that, if i called _modelCahnge for a property, it refreshed the whole row, and delete all the dirty cell marks. 问题是,如果我为属性调用_modelCahnge,它将刷新整行,并删除所有脏单元标记。

I stored the changed property names in an array, and after calling all the _modelChange() methods, Iterate in a loop over the array, and search for the cell by column name in the row what I searched by the dataItem's uid. 我将更改后的属性名称存储在数组中,并在调用所有_modelChange()方法之后,在数组上循环进行迭代,然后按我在dataItem的uid中搜索的行中的列名称搜索单元格。

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

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