Announcement

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

    Opening a Grid Editor via Button (Getting Selected Row Number)

    Here's my really hacky approach to creating an external "Edit" button that activates the editable fields of the selected record of a grid.

    Code:
    private int lastSelectedRecord;
    
    ToolStripButton editButton = new ToolStripButton("Edit");
    editButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            grid.startEditing(lastSelectedLocationRecord);
        }
    });
    
    ListGrid grid = new ListGrid();
    
    grid.addRowMouseUpHandler(new RowMouseUpHandler() {
        @Override
        public void onRowMouseUp(RowMouseUpEvent event) {
            lastSelectedRecord = event.getRowNum();
        }
    });
    Is there really no way to lookup the selected record(s) and then call grid.startEditing() against those? For whatever reason:
    • startEditing() with no argument just starts editing the first record--ignoring my selection.
    • ListGrid doesn't seems to support retrieval of selected record *numbers*--just ListGridRecord objects.
    • startEditing() only accepts record *numbers* as input
    I'm sure this issue has been asked already, but I havne't figured out the right search terms. :/

    #2
    getRecordIndex() goes from a Record instance to its index, so this problem has a less-than-one-line solution.

    Comment


      #3
      Duuurp. That's what I was looking for. Thank you!

      Comment

      Working...
      X