Announcement

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

    ListGrid Form Binding, update - operation

    Hello everybody,

    i am facing a problem that i am not able to handle. My goal is to bind a Dynamic Form to a ListGrid in order to use the form to change records that are displayed in the grid.

    Code:
    //the datasource
    final POGridDS poDs = DataSourceFactory.getInstance().getPoDataSource();
    
    //the grid that displays the reports data
    final ListGrid poGrid = createGrid(poDs);
    
    //the detailform to edit a record
    final DynamicForm detailForm = createDetailForm(poDs);
    
    //the clickhandler that is responsible for giving the editing possibility in the form
    poGrid.addRecordClickHandler(new RecordClickHandler() 
    {  
    	public void onRecordClick(RecordClickEvent event) 
            {  			
                 detailForm.reset();  
    	     detailForm.editSelectedData(poGrid);  
    	}  
    });
    
    IButton updateButton = new IButton("Save");  
    updateButton.addClickHandler(new ClickHandler() 
    	{  
    		public void onClick(ClickEvent event) 
    		{  
    			detailForm.saveData();
    		}  
    	});
    
    private DynamicForm createDetailForm(POGridDS ds)
    {
    	DynamicForm form = new DynamicForm();  
    	form.setIsGroup(true);  
    	form.setGroupTitle("Update");  
    	form.setNumCols(4);  
    	form.setLongTextEditorThreshold(201);
    	form.setDataSource(ds);
    		
    	return form;
    }
    
    private ListGrid createGrid(POGridDS ds)
    {
    	final ListGrid list = new ListGrid();
    
    	list.setHeaderHeight(20);
    	list.setWidth100();
    	list.setHeight100();
    	list.setDataSource(ds);
    	list.setAutoFetchData(true);
    	list.setAlternateRecordStyles(true);
    	list.setShowAllRecords(false);
    	list.setShowFilterEditor(true);
    	list.setDataPageSize(50);
    	list.setAutoFitData(Autofit.HORIZONTAL);
    	list.setAutoFitMaxColumns(7);
    	list.setFilterOnKeypress(false); //every time a key is pressed the data is filtered
    	list.setLongTextEditorThreshold(201); //the size of the column for which on other filter is displayed
    	list.setOverflow(Overflow.AUTO);// 
          
            return list;
    }
    The DataSource is a RestDataSource that is calling a servlet that return the expected XML data. Fetch operation uses GET, update uses POST. The update operation does not return a response, but updates the data on the serverside. A new fetch operation will get the updated data.

    The update operation doesnt work like expected. After saving the form by hitting the button, the data is updated serverside but the grid displays the data before the update.

    Is it possible that the grid updates itself after saving the changed data ito the datasource?

    Best Regards and thanks in advance
    Jakob

    #2
    RestDataSource expects a response on update/add requests that shows the data-as-saved. Provide that response and the cache will be updated automatically.

    Comment


      #3
      thanks so far, but can you post an example what this response should include. Is there a general overview what XML request/response should include?
      Last edited by jakob; 20th Feb 2009, 00:36.

      Comment


        #4
        Yes - the docs for RestDataSource.

        Comment


          #5
          Ignore ...
          Last edited by chris@umed.io; 9th Jan 2020, 11:31. Reason: I posted to the wrong post

          Comment

          Working...
          X