Announcement

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

    ListGrid, setSelectionAppearance, se-/deselect record on the fly?

    Hallo,
    I'm use setSelectionAppearance(SelectionAppearance.CHECKBOX) by ListGrid

    How can i per default select a new record?

    Code:
    . . . 
    ListGrid listGrid = new ListGrid();
    listGrid.setSelectionAppearance(SelectionAppearance.CHECKBOX)
    . . . 
    
    IButton add = new IButton("add","Add record");
    add.addClickHandler(new ClickHandler() {
    
    	    @Override
    	    public void onClick(ClickEvent event) {			
    		listGrid.startEditingNew();
    
    		
    	    }
    	});

    #2
    Two ways to do it, but either result in basically this:
    Code:
    grid.startEditingNew();
    grid.cancelEditing();
    grid.selectRecord(countryGrid.getRecords().length-1);
    grid.startEditing(countryGrid.getRecords().length - 1, 1, false);
    You could remove the selectRecord() if you has setSelectOnFocus(true), but otherwise that is the general way to do it. Note column=1 was only my example.

    Comment


      #3
      Thanks, but it does not work correct. There will always select the same record, and there is no new record.
      What am I doing wrong?

      Code:
      grid.startEditingNew();
      grid.cancelEditing();
      grid.selectRecord(grid.getRecords().length-1);
      grid.startEditing(grid.getRecords().length - 1, 1, false);

      Comment


        #4
        So I modified this example from the showcase: http://www.smartclient.com/smartgwt/showcase/#grid_editing_new_row
        but I think I posted the wrong code, don't use cancelEditing(), use endEditing(), otherwise the rest was the same but for that showcase example had to use column 2 in startediting, since the flag field was editable.

        Comment


          #5
          thx.
          it's work.

          Code:
          grid.startEditingNew();
          grid.endEditing();
          grid.selectRecord(grid.getRecords().length-1);
          grid.startEditing(grid.getRecords().length - 1, 1, false);

          Comment

          Working...
          X