FlexGrid AllowAddNew Custom handler

Posted by: arubin.karasuka on 8 September 2022, 5:20 pm EST

  • Posted 8 September 2022, 5:20 pm EST

    Based on this Adding and removing rows example.
    I have 2 questions to ask.
    1. If I select a cell on the last row, it will add an empty row to the last. Without adding any data to the selected row, I click on a cell of the last row and it will add another empty row. Is there any way to prevent to add empty rows more than 2 or prevent to add when there's empty data row.

    2. Is there a way that the last empty row can have empty cells? Some cells have buttons and checkboxes, the empty row also displayed button and checkbox.

    I think those 2 can be done in custom handler of AllowAddNew but don't know how.
    Any help is much appreciated.
  • Replied 11 September 2022, 6:35 pm EST


    You can achieve both requirements by referring to the below points:

    1. You may handle the cellEditEnded event of FlexGrid and check if 2 empty rows already exist or not and based on that prevent empty row addition into the grid. You can refer to the sample link below for the implementation.

    2. You may handle the formatItem event of FlexGrid and remove the button and checkbox elements from the empty row. Please refer to the sample link for implementation.

    Sample link: https://stackblitz.com/edit/js-ygreel?file=index.js

    Let us know if you face any issues.

  • Replied 15 September 2022, 11:52 pm EST

    Sorry for late reply and thank you for your response.
    I managed to solve problem #1 before I see your response.
    My solution is quite similar to yours, except that I check if it's last row and if it's a cell, I emptied the content of the cell. For problem #2, I was hoping there's a way to override the allowaddnew event, so I just adapt your suggestion as a workaround.

    I still have several problems regarding flexgrid, I will open a new topic as it is not related to this anymore.

    Again, thank you and regards,
  • Replied 18 September 2022, 11:07 pm EST

    Hi again,

    Unfortunately, the workaround to delete row if there are 2 or more empty data is not acceptable.
    The checking should be done before the new row is inserted to the grid.
    Any possible way to add condition before adding new empty row?


  • Replied 18 September 2022, 11:24 pm EST


    I'm afraid there isn't any specific event to handle the allowAddNew, however, you can refer to the rowAdded event of FlexGrid which gets triggered when a new row gets added to the grid. Please refer to the API link below for reference:


    Yes, you can create a new ticket for the issue you have faced. We would be happy to help you out.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels