View Full Version : GridPanel -> Editable -> DirectMethod Question

Jun 11, 2020, 2:48 PM
Copying from the following example:

[DirectMethod(Namespace = "CompanyX")]
public void Edit(int id, string field, string oldValue, string newValue, object customer)
string message = "<b>Property:</b> {0}<br /><b>Field:</b> {1}<br /><b>Old Value:</b> {2}<br /><b>New Value:</b> {3}";

// Send Message...
X.Msg.Notify(new NotificationConfig()
Title = "Edit Record #" + id.ToString(),
Html = string.Format(message, id, field, oldValue, newValue),
Width = 250,
Height = 150


As I understand - In the Edit function above the
this.GridPanel1.GetStore().GetById(id).Commit(); call is supposed to apply the changes within the Store object. How do I subscribe to the update event to have my code notified of the changes so that I could make updates in the underlying DB? What is the best way of doing that?


Jun 11, 2020, 3:37 PM
Hello @Dennis!

In the way you show you are already at code behind, I believe you can just add your server logic to do the update (if anything really changed db-wise).

But as far as automated update triggering is concerned, you can tie store change events to server-side calls in a more seamless way using store server events.

There are examples on that under Grid Panel > Saving Variations in examples explorer:
- GridPanel > Saving_Variations > HttpHandler (https://examples5.ext.net/#/GridPanel/Saving_Variations/HttpHandler/)
- GridPanel > Saving_Variations > StoreCustomLogic (https://examples5.ext.net/#/GridPanel/Saving_Variations/StoreCustomLogic/)
- GridPanel > Saving_Variations > StoreEvents (https://examples5.ext.net/#/GridPanel/Saving_Variations/StoreEvents/)
- GridPanel > Saving_Variations > WebService (https://examples5.ext.net/#/GridPanel/Saving_Variations/WebService/)

I believe the simplest here to start with would be the second example, GridPanel > Saving_Variations > StoreCustomLogic (https://examples5.ext.net/#/GridPanel/Saving_Variations/StoreCustomLogic/), but you may want to check out the others to see some other options at your disposal.

But again, in the scenario you show, it doesn't look very performatic to rely on a server event triggering a client event that calls back a server event. If you're already in the Edit() direct method server handler, you'd better off handling the database changes at that point instead of changing the value in the grid, applying (committing) the change, and then letting the store call back the server. It really depends on the approach you choose to keep your displayed grid in sync with the database on server though.

Hope this helps!