BatchEdit adding a blank record

4 posts, 0 answers
  1. Andy F.
    Andy F. avatar
    46 posts
    Member since:
    May 2006

    Posted 01 Sep 2015 Link to this post

    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?

  2. Viktor Tachev
    Admin
    Viktor Tachev avatar
    2470 posts

    Posted 03 Sep 2015 Link to this post

    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
  3. Andy F.
    Andy F. avatar
    46 posts
    Member since:
    May 2006

    Posted 03 Sep 2015 in reply to Viktor Tachev Link to this post

    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.
  4. Viktor Tachev
    Admin
    Viktor Tachev avatar
    2470 posts

    Posted 08 Sep 2015 Link to this post

    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
Back to Top