Announcement

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

    ListGrid.addData does not update the UI?

    Hello,

    Using:
    SmartClient Version: SC_SNAPSHOT-2012-02-27_v8.2p/PowerEdition Deployment (built 2012-02-27)


    I am doing a pretty simple thing, namely adding a ListGridRecord to a ListGrid, but somehow the grid is not *visually* updated, although the data IS stored in the SQL database.

    Here is my listgrid initialization:
    Code:
    public class OrderGrid extends ListGrid {
       public OrderGrid(){
    		Log.debug("Initializing OrderGrid");
    		
    		setAlternateRecordStyles(false);
    		setCellHeight(32);
    		setDataSource(orderedDishes);
    		setAutoFetchData(false);
    		setCanEdit(true);  
    		setModalEditing(true);
    
    		setShowFilterEditor(true);
    		setCanSelectText(true);
    		setCanDragSelectText(false);
    		setFetchOperation("JoinOnPkg");
    		setAddOperation("addWithPkg");
    		setUpdateOperation("updateWithPkg");
    		setDoubleClickDelay(30);
    		setEditEvent(ListGridEditEvent.DOUBLECLICK);
    		setFilterOnKeypress(true);
    		setAllowFilterExpressions(true);
    		setListEndEditAction(RowEndEditAction.DONE);
    		setCanRemoveRecords(false);    
    		setAutoSaveEdits(true);
    		setCanDragRecordsOut(false);
    		setCanAcceptDroppedRecords(true);
    				
    		setGroupByField("pkgName");
    				
    		setGroupStartOpen(GroupStartOpen.ALL);
       }
      //...
    }
    Here the code I use to insert the record:
    Code:
    ListGridRecord toAdd = new ListGridRecord();
    toAdd.setAttribute("Order__id",order.getAttribute("Order__id"));
    toAdd.setAttribute("Dish_id", rec.getAttribute("Dish_id"));
    toAdd.setAttribute("amountOrdered",amountItem.getValue());		
    grid.addData(toAdd);
    Am I missing something obvious here? It's not much different, apart from some the grid initialization, from this example right?:
    http://www.smartclient.com/smartgwt/...operations_add

    #2
    Try this at the end :
    grid.markForRedraw();

    Comment


      #3
      Thanks, I tried that, but it didn't help...

      I'm a bit lost on this one, since it should be a simple thing to build.

      Comment


        #4
        There's a FAQ on grids not updating with troubleshooting steps.

        Comment


          #5
          Thank you, although I've read the FAQ of course, I forgot that this entry was in there.

          Appearantly this was exactly what I did wrong:
          If you do not see any logs about updating caches, this
          indicates the grid in question is not using a ResultSet / ResultTree at all, probably because you
          either did not call fetchData() / filterData(), or because you called setData() with a data model
          such as a RecordList or Tree, both of which are not aware of DataSources and will automatically
          update caches.
          Because my UI was showing different views of data from the same datasource (one of which being a listgrid), I did one dataSource.fetchData call, and then did grid.setData(aRecordList);

          Now I did a grid.fetchData() instead. I'll optimize the number of roundtrips later, there are a few strategies to try...

          Thanks! Hope this helps other people as well :-)

          Comment

          Working...
          X