This is a migrated thread and some comments may be shown as answers.

Is it possible to call one event of Kendo UI inside another event?

10 Answers 660 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Stefan
Top achievements
Rank 1
Stefan asked on 01 Dec 2015, 11:26 AM

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

Sort by
0
Nikolay Rusev
Telerik team
answered on 03 Dec 2015, 09:26 AM

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
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Stefan
Top achievements
Rank 1
answered on 03 Dec 2015, 11:25 AM

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.

0
Stefan
Top achievements
Rank 1
answered on 07 Dec 2015, 05:11 AM

Hi Nikolay,

 

Can you please help me regarding this issue?

 

0
Nikolay Rusev
Telerik team
answered on 07 Dec 2015, 08:21 AM

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)

 

http://jsfiddle.net/4x873x39/

 

Note that there are some JavaScript errors in the original code.

 

Regards,
Nikolay Rusev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Stefan
Top achievements
Rank 1
answered on 07 Dec 2015, 12:37 PM

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?

0
Nikolay Rusev
Telerik team
answered on 09 Dec 2015, 08:41 AM

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
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Stefan
Top achievements
Rank 1
answered on 13 Dec 2015, 08:27 AM

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?

 

0
Nikolay Rusev
Telerik team
answered on 15 Dec 2015, 01:52 PM

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
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Stefan
Top achievements
Rank 1
answered on 17 Dec 2015, 08:36 AM

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.

0
Nikolay Rusev
Telerik team
answered on 21 Dec 2015, 07:52 AM

Hello Stefan,

 

http://jsfiddle.net/r0ojcee8/

 

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
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Grid
Asked by
Stefan
Top achievements
Rank 1
Answers by
Nikolay Rusev
Telerik team
Stefan
Top achievements
Rank 1
Share this question
or