ListGrid refreshing too fast?

Hi,
I know that sounds like a weird subject but its the only explanation I can think of to my issue.

I have a basic DynamicForm with some text fields. I also have a list grid with same data as the DynamicForm, but a different data source (for display reasons). When I enter data in the form and hit the Save button, I call a function that saves the data from the form, clears the grid, hides the form, then refreshes the grid. The goal is to display the data I just saved from the form in the Grid (just like if they did have the same datasource). When I refresh, I don’t see the data I just saved. As a test I put in a button that did the SubDomainGrid.fetchData({parentDomainId:vParentDomainID}); just like in the function and it reloads the grid with the latest data, including the record I just entered.

Here is the function I call on the click of the save button of the DynamicForm.

click: function () {  
  frmAddSubDomain.saveData();
 			       
  SubDomainGrid.setData([]);
  
  frmAddSubDomain.hide();  //Hide the Form
				 
  frmAddSubDomain.clearValues();   //Clear all the Values in the Form
				   
  SubDomainGrid.fetchData({parentDomainId:vParentDomainID});  //repopulate the grid 

}

Is there anything I can do to only do the fetch after the saveData is completed, or delay the fetch, or any other things I could try to.

Thanks for the help, hope this made sense.

Fuzz

Hi Fuzz,

Do you really need a different DataSource for the form? Are you aware that by setting dynamicForm.fields in addition to dynamicForm.dataSource, you can hide fields, show additional fields not present in the DataSource, do whatever you want with layout, etc?

Even if you use a separate DataSource, you could use dataSource.updateData() or dataSource.addData() on the DataSource by the grid to create a new record from the values in the form (form.getValues()) and cache update would still be automatic and you wouldn’t be dropped your cached dataset.

Finally if your current approach is really, really required for some reason :slight_smile: .. if you are using the SmartClient Server, you can enable queuing (RPCManager.startQueue()) to ensure in-order execution of your save and subsequent fetch (this also makes it one HTTP turnaround).

If you aren’t using the SmartClient server, you can use the callback parameter of saveData() so that your fetchData() call happens only after the saveData() call completes (saveData() is asychonrous).