Can someone answer how to call databound event inside save event in Kendo UI?
The requirement is to access the KendoGrid data dynamically (as and when it changes). (I tried using the change function, but it is not firing.)
So I think, my requirement would be possible by calling the databound event inside the save function, so that I get the latest value as well as and when it changes.
P.S:- I cant use this.refresh(); function inside the save function because, there's another requirement for me to add a new row when pressing enter key.
10 Answers, 1 is accepted
Hello Stefan,
dataBound event is triggered inside the refresh method, which on another hand is wired to DataSource change event except when there is open editor.
I'm not sure why you need this. What this means `The requirement is to access the KendoGrid data dynamically (as and when it changes)`? Can you please explain a bit more in order to suggest how you can achieve the scenario?
Regards,
Nikolay Rusev
Telerik
Hi Nikolay,
http://jsfiddle.net/aravind_93/Lw6awf6g/
When i enter data in a cell and then press tab key, it is going to the top left most cell.
This is because of this.refresh i believe.
The requirement, for me is to access the cell value as it changes.
For example when i enter some data in a cell and then press enter key, i need to access that particular data then!
That's why i wanted to call databound event inside save event.
Hi Nikolay,
Can you please help me regarding this issue?
Hello Stefan,
refresh method will repaint the widget and the `current` (highlighted item) will be reset.
If understand correctly you need to execute the code from dataBound event handler on save. If this is the case you can move the code from dataBound handler in a new function, call that function inside dataBound handler. Then you can call that function again inside save event handler, but wrapped in setTimeout(function() { call_my_function(); }, 1)
Note that there are some JavaScript errors in the original code.
Regards,
Nikolay Rusev
Telerik
Hi Nikolay,
In the link to your js fiddle, if i am in the last row and typed some data and then pressed the enter key, it goes to the new row, no issues. Agreed.
But in that particular cell when you type some data and press the enter key, it doesnt create a new row, instead it just goes to the top left corner cell.
Can you pls check that?
Hello Stefan,
This is due to the custom code for enter key handling. I've upated it so that it works as you expect - http://jsfiddle.net/4x873x39/1/
Regards,
Nikolay Rusev
Telerik
Hi Nikolay,
Thanks a lot.
Before closing, I would also like to know whether it's possible to access the value of the "time required" column as and when it changes so that, the "hours" can be updated.
Now, it gets updated only when a new row is created.
I have tried it inside databound event.
(But, as i told earlier, it will work if i call this.refresh function inside save. But the thing is, the earlier problem[The cell goes to the top leftmost cell if tab is pressed after entering some value in the cell] )
So, that's why, is there any way to control it?
Hello Stefan,
You can get the value of any field in the save event handler. For example see the alert when you save cell in this example - http://jsfiddle.net/uLf6vyqt/1/
Regards,
Nikolay Rusev
Telerik
Hi Nikolay,
I agree with you on that, but I'm trying to access the value of "Aggregates" function(which loads only after refresh is called).
I wanted to navigate to the next cell wherever i am currently in.
Hello Stefan,
In this case you should call grid.refresh inside save event. However this way you will loose currently highlighted cell as it will be reset to the top left corner.
You can try to persist its state on dataBinding, dataBound event and then inside repaint you can use grid.dataSource.aggregates() to get computed aggregates values.
Regards,
Nikolay Rusev
Telerik