How can I set value programmatically to a cell in Treelist from javascript after the data is loaded?
Say I have quantity and price, I need to update the total amount column when I change value quantity or price.
1 Answer, 1 is accepted
0
Nikolay
Telerik team
answered on 23 Aug 2022, 08:26 AM
Hello Josetuttu,
In the given scenario it is best to display the total amount column with a template where its value is the quality multiplied by the price. This way once the price or the quantity is updated the total amount will automatically update as well.
template: "#= data.Price*data.Quantity #"
Another option to update a model property is using the set() method.
Let me know if this is what you are looking for.
Regards,
Nikolay
Progress Telerik
The Premier Dev Conference is back!
Coming to you live from Progress360 in-person or on your own time, DevReach for all. Register Today.
Thanks Nikolay. I was trying the set method itself. But the set method is expecting 3 parameters and I couldn't find any documentation or example regarding that. The problem I faced was that the column I was trying to set was marked as editable false in the schema since it is a calculated field. This was preventing setting the value to the field. I assume this is not a desirable behavior as making it editable will allow user to change value of a calculated field. Nonetheless, I made it editable in the schema and close the cell when user tries to edit it.
Nikolay
Telerik team
commented on 01 Sep 2022, 08:08 AM
Hi Josetuttu,
Thank you for following up.
Closing the cell the user tries to edit is a valid solution. You can also use the columns.editable configuration and set the function no return false.