GridPanel -> Editable -> DirectMethod Question

  1. #1

    GridPanel -> Editable -> DirectMethod Question

    Hello,
    Copying from the following example:
    https://examples5.ext.net/#/GridPane..._DirectMethod/

        [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
            }).Show();
    
            this.GridPanel1.GetStore().GetById(id).Commit();
        }
    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?

    Thanks,
    Dennis.
  2. #2
    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
    - GridPanel > Saving_Variations > StoreCustomLogic
    - GridPanel > Saving_Variations > StoreEvents
    - GridPanel > Saving_Variations > WebService

    I believe the simplest here to start with would be the second example, 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!
    Fabrício Murta
    Developer & Support Expert

Similar Threads

  1. [CLOSED] Question about DirectMethod/DirectEvents call
    By feanor91 in forum 3.x Legacy Premium Help
    Replies: 2
    Last Post: Aug 06, 2015, 11:43 AM
  2. Editable Grid Panel with [DirectMethod]
    By ChrisO in forum 2.x Help
    Replies: 1
    Last Post: Nov 27, 2012, 3:37 PM
  3. [CLOSED] Strange question about directmethod call
    By feanor91 in forum 2.x Legacy Premium Help
    Replies: 8
    Last Post: Nov 12, 2012, 12:37 PM
  4. [CLOSED] Question about directmethod (another one)
    By feanor91 in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Jun 14, 2012, 7:22 AM
  5. Replies: 1
    Last Post: Sep 13, 2011, 5:19 PM

Tags for this Thread

Posting Permissions