EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: swader on March 27, 2012, 11:29:28 PM



Title: Datagrid - Deleting a newly created row
Post by: swader on March 27, 2012, 11:29:28 PM
When I add a new row to my datagrid with the detailview helper, the values are populated properly because I call "reload" immediately afterwards. But the new row, as an object, has only one value: Object { isNewRecord=true}. Now, when I punch delete, it tells me it can't find the given index,

Code:
data.rows[_49f] is undefined
[Break On This Error]

_3ca(_4a2,opts.idField,data.rows[_49f][opts.idField]);

Now, if I refresh, this row is ok and can be deleted. But I can't delete it IMMEDIATELY after creating it, and I would like to.


Title: Re: Datagrid - Deleting a newly created row
Post by: stworthy on March 28, 2012, 01:42:09 AM
If you define the 'idField' property, every records should have a key field. Add key field to your added record or remove the 'idField' property from datagrid.


Title: Re: Datagrid - Deleting a newly created row
Post by: swader on March 28, 2012, 02:36:36 AM
Removing the idField from datagrid worked, thanks!
What does that option do, anyway? I couldn't figure it out from the documentation.


Title: Re: Datagrid - Deleting a newly created row
Post by: stworthy on March 28, 2012, 03:34:03 AM
The idField indicate the key field, it is not necessary. If the idField is set, the selected records will be remembered while navigating records through multi page.


Title: Re: Datagrid - Deleting a newly created row
Post by: swader on March 28, 2012, 03:46:36 AM
Interesting, thank you! That might come in handy later on.