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

3.1k Views Asked by At

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}); The other way is the set() method: dataItem.set("propertyName","value"), but I don't use it because is extremely slow.

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.

The following loop does the dataItem update and marking the field as dirty:

            $(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.

2

There are 2 best solutions below

1
On BEST ANSWER

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

Check the article out, this talks about highlighting multiple cells with dirty flag:

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

1
On

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/

The problem was that, if i called _modelCahnge for a property, it refreshed the whole row, and delete all the dirty cell marks.

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.