I am updating a grid cell with a date value on a button click from a custom command in the row (see code below). I am able to successfully add the value to the cell but I would like to have the cell show the red triangle in the upper left corner (see attached pic) that shows the user the value in the cell has been edited.
7 Answers, 1 is accepted
You can either manually add the dirty indicator the edited cell (by appending the span element used for the indicator) or call the following method after changing the value:
On a side note, please have in mind that the correct way of changing values is through the set method of the model: dataItem.set("fieldName", value);
Hope this helps.
Telerik by Progress
I am using the data.set method in my code (see below) but the dirty flag is not being displayed. Do I need to do more to show the dirty flag?
The set method should be used in combination with manually appending the span element for the dirty flag to the cell:
You can refer to the following example for manually adding a dirty flag (although it is a different requirement, you can have it as a reference):
However, using the private _modelChange method should handle the changing of the value and the appending of the dirty flag, so I would suggest that you test that approach first and see if everything will work as expected with it.
Telerik by Progress
I was able to get an editable, sortable drop down for the ticket that we had discussed recently. (I ended up finding some time to delve further.)
I found this link:
very helpful in constructing the solution.
I came across that link from this link:
I was also able to get the dirty flag to appear using the manual append suggestion and the link you had provided
Thank you for that!
Just for a deeper understanding and to explore another option, I was wondering if you could clarify the _modelChange option. I don't understand what how to replace "grid.dataSource.view()" with the model that I am editing.
I included my attempt do so within my update function (which appears within my editor template file):
I commented out my attempt to use _modelChange after I could not get it to work and switched to the manual append method.
Could you please provide additional detail on the _modelChange option?
With the latest version you could use the "set" method and it will add the dirty indicator internally:
As for the currently edited dataItem, this is the line that get reference to the item:
Nevertheless, since the _modelChange is a private method I would not recommend using it, because it could change over time and it is not part of the public API where we are trying to avoid breaking changes.
Hope this helps.
I think I understand. Can you please confirm the below?
1. Because the dirty indicator is set internally, the first block below can be replaced with the second:
2. But I still need to include a check for the dirty flag and append the dirty flag class in the UI:
Is the above correct?
I will take over the ticket as my colleague Konstantin is away.
I went over the communication and can confirm that the suggested approach by my colleagues could replace the original logic. Also, the ClientTemplate is needed as well in order to call the function.
If the flag has to be added via CSS(and HTML) based on the code I can assume that the model modification and setting the flag visually can be done together in the same function without the need of a separate one. Instead of returning only the span I can suggest returning the span and the value of the DropDown and only the value if the condition is not met.
If this is not possible, please provide an example demonstrating the issue and we will gladly provide a suggestion best suited for it.