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

BatchEdit adding a blank record

3 Answers 84 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Andy F.
Top achievements
Rank 1
Iron
Andy F. asked on 01 Sep 2015, 04:35 PM

I have a RadGrid using Batch Edit mode and the data being editing/displayed by the grid is a single column.

When I Add Record, and then press return without entering any text, the data is accepted and BatchEditCellValueChanging client event is not fired and a blank record is added to my data to be saved.  If I edit a cell with content already in it, clear the contents, then press Enter, BatchEditCellValueChanging is fired, and I can cancel the event to prevent the change from taking place.

How do I intercept the Add Record situation on the client side and prevent the blank record from being added to the client-side data?

3 Answers, 1 is accepted

Sort by
0
Viktor Tachev
Telerik team
answered on 03 Sep 2015, 04:21 PM
Hello Andy,

In order to prevent empty data from being entered to the data source you can add validation to the RadGrid columns. Some of the columns provide a RequiredFieldValidator out of the box. You just need to set the ColumnValidationSettings-EnableRequiredFieldValidation property to true. Check out the following article for additional information.


You can also see the functionality in action in the online example below:




Regards,
Viktor Tachev
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Andy F.
Top achievements
Rank 1
Iron
answered on 03 Sep 2015, 04:38 PM
I tried that, but that didn't help, because it would fire the validator and prevent me from getting out of the insert entirely unless I cancelled ALL changes to the grid, which is a bit extreme.  The client side events have a way to intercept the issue on update, just not on add record.
0
Viktor Tachev
Telerik team
answered on 08 Sep 2015, 11:20 AM
Hello Andy,

It is not necessary to cancel all changes if you would like to remove only the currently inserted row. Check out the following online example that illustrates the behavior.


You can make some changes to the grid and click on Add new record. To remove the new row click on the delete button in it. You will notice that the previous changes are retained.

Regards,
Viktor Tachev
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Grid
Asked by
Andy F.
Top achievements
Rank 1
Iron
Answers by
Viktor Tachev
Telerik team
Andy F.
Top achievements
Rank 1
Iron
Share this question
or