PDA

View Full Version : form grid and store



michael melsen
9 Feb 2010, 11:49 PM
Hi guys,

I'm struggling with the combination of a two grids (with a store each) and a form that are being used to create groups of persons. I have the situation where I have this panel containing two grids which marks two groups. the left grid shows persons who are not in a group and the right panel, which can be filled by drag and drop, are persons who will be in a new group. Above these grids, in the same panel, there are some form fields that are used to show information about existing groups and to enter information like groupname in case a new group is created.

I have been thinking that there are two httprequests necessary at initiation: one to get available persons who are not in a group, and another who will retrieve an existing kind of group with group information. The information of available persons are stored in a store even as the selected persons who are forming a group but these come in a different store, just like the grid_to_grid_dnd example. The difficulty I'm experiencing here is dealing with this second grid and the information of the form. I have been able to create an ajax.request and submit the ids of the persons combined with the form information to the server, but have a problem with retrieving. Upon retrieving the store has to contain data as wel as the form. Is it possible to fill the store and form through one request as well without the need of having to include the url attribute in the formpanel and the url attribute of the store?

kind regards,

Michael

Mike Robinson
10 Feb 2010, 8:20 AM
Here's a trick that I've used to some good success:

(1) Use an Ajax.Request to ask the host for both pieces of information at once. Let's say that the host returns a structure containing two arrays of structures.

(2) The success-handler now takes this response and stuffs the data from each of the two arrays into an ArrayStore object. You can now manage the two grids using these two stores. The host is not being made aware of any of the changes-in-progress.

(3) At some point, you have to tell the host about the changes. I often like to give users the complete freedom to mash the Cancel button and to have thus done absolutely nothing. So, in an "OK button" handler, I basically prepare and fire off another AJAX request, this time giving the host the newly-updated status in much the same format that was used to send the status down to me.

This is a fine technique to use, I think, when there's a reasonable amount of data in both lists, such that neither client-side storage nor transmission-time would be a problem. The host-side support amounts to exactly two calls: "get status" and "replace status." This scenario of course presupposes that two people are not attempting to update the same thing at the same time: guard against race-conditions in some suitable way if this consideration is relevant.

michael melsen
10 Feb 2010, 11:45 PM
Hi Mike,

thanks for the reply. I have a question about your second statement:

"The success-handler now takes this response and stuffs the data from each of the two arrays into an ArrayStore object. You can now manage the two grids using these two stores. The host is not being made aware of any of the changes-in-progress."

I also have the form information that describes the kind of group selected. From your example I could use the same ajax.request but then I need to split this data into the two datastores for the grids, but I also have the group description data. Should I use a different kind of store for this or is this not possible to use with a form panel?

cheers,

Michael