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

Using .get(ID) to access a new datarow, not working with creating a new row

2 Answers 221 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Brandon
Top achievements
Rank 1
Brandon asked on 19 Dec 2011, 04:07 PM
I'm simulating checkboxes by using spans that do something when clicked.  Everything is working fine when using existing data because I can use .get(ID) to access the data row and then use .set to toggle the value (which sets the modified flag and all that).  However, when adding a new row to the table, there is no ID, and I can't use the "get" function to access it.  I have a semi-working jsfiddle example. 

Use the "add new cell text message" button, I haven't implemented the default "add row" button. 

Also, how do I have a function I wrote be called after the "Add New Row" button does it's work?


http://jsfiddle.net/brandoncharnesky/KcQ9T/

2 Answers, 1 is accepted

Sort by
0
Accepted
Rosen
Telerik team
answered on 20 Dec 2011, 05:56 PM
Hi Brandon,

Indeed, the new items raw data does not have id set as you would expect. However, there is actually a private id assign, which is use for tracking. There are two ways to access the id one is through the model instance created when the model is attached. The other one is by using the "static" id function of the Model type. I have modified your sample to demonstrate the use of the second option as it is more appropriate in your scenario:

Regards,
Rosen
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Brandon
Top achievements
Rank 1
answered on 20 Dec 2011, 07:05 PM
Rosen,

That works perfectly now.  Thank you!

I'm very encouraged that kendo can handle this "relatively" complicated template without too many issues.
Tags
Grid
Asked by
Brandon
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Brandon
Top achievements
Rank 1
Share this question
or