Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    ListGrid: Restrict number of records added to it

    Hi,

    I am working on a listgrid where I would need to restrict the number of records added to it. Lets say 100.

    I have an add button which invokes startEditingNew(), where I can restrict. But on pressing the down arrow from an currently editing row, a new row is added (I am aware that this is normal behavior and we need this).

    I have tried restricting from RowEditorExitHandler by getting the rowNum from event. But, if I cancel the event and prevent it from adding next row, I am not able to save changes made on the last row.

    Is there any other way to handle this on the client side? Please let me know.

    Thanks

    #2
    Originally posted by rajesh.vashista
    I am not able to save changes made on the last row.
    why you can't ?

    Comment


      #3
      Originally posted by jmichelgarcia
      why you can't ?
      Simply put, when I cancel the editorExit event, the values entered in the grid cells are not saved (Correct behavior I guess).

      However, I figured out a way to do this with the following code

      Code:
      listGrid.addRowEditorEnterHandler(new RowEditorEnterHandler() {
      				@Override
      				public void onRowEditorEnter(RowEditorEnterEvent event) {
      					if (event.getRowNum() > 99) {
      						SC.warn("You have exceeded the number of records allowed");
      						listGrid.cancelEditing();
      					}
      				}
      			});
      Is there a more elegant way to solve this? I couldn't find any.
      Something like setting ListGrid.setMaxRecords(100); would be really helpful.

      Thanks

      Comment


        #4
        This solution seems great to me. You need to submit a request (i guess) if u wanna ask for this. But as i said, your solution seems pretty good

        Comment

        Working...
        X