PDA

View Full Version : How to prevent new but unedited(empty) grid record from being submitted on save?



JohnJones357
16 Jan 2014, 9:02 AM
I have an editable grid with an add button that adds a new, empty row. You can add multiple reports records then on save, these new records get passed to the backend. In the case where user adds an empty record to add another report but doesn't in fact edit that record, and then clicks save, that empty, unedited, record will get passed to the backend. How can I prevent this from happening?

Gary Schlosberg
16 Jan 2014, 10:51 AM
Can you use the beforesync (http://docs.sencha.com/extjs/4.2.1/#!/api/Ext.data.Store-event-beforesync) event to check for those records before sending on to server?

palakurthivishal
16 Jan 2014, 10:08 PM
Hello JohnJones357,
You can do a workaround by committing the grid changes when the add button is clicked, later when the user clicks on save just get the modified records of the grid which gives you only those records which were committed previously. Just like,


grid.getStore().getModifiedRecords();