Announcement

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

    How to have a ListGrid start out with an empty row

    I have a ListGrid that may be empty when it is first displayed and the user wants to see an empty row, ready for editing. I've tried adding a draw handler like this, but it does nothing. Is there another event that I can hook into to start editing on the new record?
    Code:
    grid.addDrawHandler(new DrawHandler() {	
    	@Override
    	public void onDraw(DrawEvent event) {
    		if (grid.getDataAsRecordList().isEmpty()) 
    			grid.startEditingNew();
    	}
    });

    #2
    What's not working - are you managing to call startEditingNew() or is the dataset actually non-empty?

    Do you want this grid to be databound or not, in other words, should "add" operations from other components using the same DataSource add records to this grid? If you want it databound, you should be calling fetchData() and using the callback to startEditingNew(), or if you want to force not initial records, you should provide a ResultSet as the data model before calling startEditingNew().

    Comment


      #3
      It is a client-only data source and I'm using setData() to populate it initially. All of that happens before it is first drawn. I just added that code back in and it is now working. Either there was a bug that was fixed in the new build or I was doing something else wrong before. In either case, all is OK now. Thanks.

      Comment

      Working...
      X