I have a requirement to update all selected rows with given value. The grid is using the multi select mode and the column I am updating has a name of "status" e.g.
<
td
name
=
"status"
role
=
"gridcell"
id
=
"SubmissionsGrid_active_cell"
class
=
""
>Active</
td
>
The status column is a drop down list which I have been able to get working using the example in this article.
I am trying to change the value for each selected row and flag the cell as dirty using the following code:
$(
'#myButton'
).click(
function
() {
var
grid = $(
"#SubmissionsGrid"
).data(
"kendoGrid"
);
$.each(grid.select(),
function
(index, row) {
var
cell = $(row).find(
'[name="status"]'
);
cell.addClass(
"k-dirty-cell"
).prepend(
"<span class='k-dirty' />"
);
var
data = grid.dataItem(row);
data.set(
'Status.Id'
,
'3'
);
data.set(
'Status.Description'
,
'Rejected'
);
});
});
The problem I have is that I cannot get the dirty flag to work in conjunction with the change. If I comment out the code that changes the value the k-dirty-cell class is added successfully and the web form shows the cell is dirty however when both code blocks are used the value is chanced but the cell does not show as begin dirty.
I am using the MVC version of the grid.
Thanks
Paul
7 Answers, 1 is accepted
The "k-dirty" flag needs to be added after the grid is refreshed. This means that you need to update the data items and then to wait for the updated to be applied. Check this Dojo demo that demonstrates this approach. Note that on every grid refresh, the old "k-dirty" flags will be lost.
Regards,
Georgi Krustev
Telerik

Hi, I'm trying to manually add the dirty indicator but have no success. It seems the dojo demo is not working.
How can I manually set the dirty flag in a cell?

Hi again,
I finally could manage to add the dirty indicator but I'm now watching a weird issue. My project uses aurelia framework, polymer and some pro (grid, scheduler,...) kendo widgets.
I have a complex scenario where I'm supplying a custom editor for cell edition in one of the columns. This custom editor opens a polymer modal to allow value edition. The strange issue is that once the modal is closed, grid seems to "refresh" and all dirty flags are removed, same effect than clicking on refresh button in data pager footer
How can I avoid this issue?
I suppose that the issue you are experiencing is related to the way Aurelia integration (or your custom one) is implemented.
I am afraid that we would not be able to provide much help here as the support service handles only built-in features of the widgets. What I would suggest you is to open a discussion in the support channels of Aurelia depending on the source of the Grid integration code.
Regards,
Georgi Krustev
Telerik by Progress

Hello Georgi,
I finally could solve the issue by keeping a copy of current dirty cells before cell edition and then, once the the edition is finished restoring dirty cells.
Anyway, I'd to know why, sometimes (not always a polymer modal is opened) the grid removes all dirty flags. What are the events or situations that force grid to refresh and remove the dirty flags? I can force this behavior by clicking on refresh button. Does grid publish an event to notify a refresh is done (or going to be done)?
The grid will remove the 'dirty' flags when its refresh method is called. It will be called when datasource changes.
The widget will raise its dataBound event when the content is re-rendered as a result of 'refresh' call.
Regards,
Georgi Krustev
Telerik by Progress

Updated dojo, just in case anyone is looking for it:
http://dojo.telerik.com/UqiqUTiV