[MVC] How to get the initial data from an edited FormPanel and send it to the controller?

  1. #1

    [MVC] How to get the initial data from an edited FormPanel and send it to the controller?

    I have a FormPanel that gets filled with editable data upon selecting a row in a GridPanel (like this example).
    I want to send the initial data from the form panel, as well as any edited data, from the View to the Controller when the "save" button is pressed, so that I can compare the changes:

    public void Compare(FormCollection newValues, FormCollection oldValues)
    {...}
    I know that I can send the newValues like this:
    .Listeners(listener => {
        listener.Click.Handler = @"this.up('form').submit({
            success : function (form, action) {
                eval(action.result.script);
            }});";
    })
    but how can I get and send the oldValues?

    The form is initially filled from a passed in @model System.Data.DataTable. I know I could probably get the values from this DataTable again, but I am new to Ext.Net, Asp.Net, C#, and MVC, and I just don't know how to do that in code.
    Last edited by KBorkiewicz; Nov 13, 2012 at 10:13 PM.
  2. #2
  3. #3
    Kind of. I already have a view like this: a GridPanel is filled with data from a DataTable that is passed in from the model with
    @model System.Data.DataTable
    and when a user clicks on a row, data in the FormPanel is filled with the data from the GridPanel and can be edited.

    However, upon editing and clicking the "save" button, I want to store both the original data and the edited data, so I can compare the two. Not sure if I should pass these to the Controller or the Model...

    This example in MVC and Razor would indeed be helpful, with this added constraint.
    Last edited by KBorkiewicz; Nov 14, 2012 at 2:38 PM.
  4. #4
    Encode the data of the first element of Form's Store and pass it as parameter, as shown bellow:
    Ext.net.DirectMethod.request({
        url: "/Example/SubmitData",
        cleanRequest: true,
        params: {
            originalData: Ext.encode(App.Store1.getAt(0).data)
        }
    });
  5. #5
    Thanks! Where should I put this and how do I call it? Could you give me the example in a sample context?



    Quote Originally Posted by RCN View Post
    Encode the data of the first element of Form's Store and pass it as parameter, as shown bellow:
    Ext.net.DirectMethod.request({
        url: "/Example/SubmitData",
        cleanRequest: true,
        params: {
            originalData: Ext.encode(App.Store1.getAt(0).data)
        }
    });
    Last edited by KBorkiewicz; Nov 14, 2012 at 4:15 PM.
  6. #6
    1 - View
    <ext:Button Text="Submit" runat="server">
        <Listeners>
            <Click Handler="submitData();" />
        </Listeners>
    </ext:Button>
    2 - JavaScript
    var submitData = function () {
        Ext.net.DirectMethod.request({
            url: "/Example/SubmitData",
            cleanRequest: true,
            params: {
                originalData: Ext.encode(App.Store1.getAt(0).data)
            }
        });
    }
    3 - Action
    public AjaxResult SubmitData(string originalData)
    {
        //Entity entity = (Entity)JSON.Deserialize(originalData, typeof(Entity));
    }

Similar Threads

  1. Replies: 1
    Last Post: Oct 05, 2012, 1:36 PM
  2. Replies: 6
    Last Post: Apr 25, 2012, 11:05 AM
  3. [CLOSED] [1.3] Send custom data on each request
    By John_Writers in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Apr 04, 2012, 5:13 PM
  4. [CLOSED] passing data from controller to 'RemoteActionSuccess'
    By jesperhp in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Nov 16, 2011, 6:48 PM
  5. Replies: 4
    Last Post: Nov 17, 2008, 8:16 AM

Tags for this Thread

Posting Permissions