How do I use the AfterEdit event of a RowEditor on a GridPanel?

Page 1 of 2 12 LastLast
  1. #1

    How do I use the AfterEdit event of a RowEditor on a GridPanel?

    Guys, first of all I was not able to find a 100% complete code for this anywhere, I copied some sample code to use on a GridPanel with an AfterEdit DirectEvent and I'm able to read this parameter from the event, is there an incapsulated method of Ext.Net to parse the results of the parameter that was created with getRowsValues in a more object oriented way?

    The Value:

    [{"lst_id":"f4bfb666-332a-4601-a8e5-aa11688c94a6","lst_created":"2010-12-23T14:40:00","lst_name":"Name!","lst_description":"List created @ 12/23/2010 2:40:00 PM","lst_date":"2011-01-01T00:00:00"}]

    The Grid:

    <Plugins>
                                <ext:RowEditor ID="RowEditor1" runat="server" SaveText="Update">
                                    <DirectEvents>
                                        <AfterEdit OnEvent="AfterEdit_GridPanel" AutoDataBind="true" IsUpload="true" Success="true">
                                            <ExtraParams>
                                                <ext:Parameter Name="Parameter1"
                                                   Value="Ext.encode(#{GridPanel1}.getRowsValues({selectedOnly : true}))" Mode="Raw" />
                                                </ExtraParams>
                                        </AfterEdit>
                                    </DirectEvents>
                                </ext:RowEditor>
                            </Plugins>
    The Event:

    public void AfterEdit_GridPanel(object  sender, DirectEventArgs e)
        {
            object Params = e.ExtraParams[0];
            //X.Msg.Notify(((Ext.Net.Parameter)Params).Params["lst_id"].ToString(), ((Ext.Net.Parameter)Params).Params["lst_name"].ToString());
            //[{"lst_id":"f4bfb666-332a-4601-a8e5-aa11688c94a6","lst_created":"2010-12-23T14:40:00","lst_name":"Name!","lst_description":"List created @ 12/23/2010 2:40:00 PM","lst_date":"2011-01-01T00:00:00"}]
            
        }
  2. #2
    Hi,

    Please see
    https://examples1.ext.net/#/GridPane...mit_Two_Grids/

    protected void SubmitGrids(object sender, DirectEventArgs e)
        {
            //JSON representation
            string grid1Json = e.ExtraParams["Grid1"];
            string grid2Json = e.ExtraParams["Grid2"];
    
            //XML representation
            XmlNode grid1Xml = JSON.DeserializeXmlNode("{records:{record:" + grid1Json + "}}");
            XmlNode grid2Xml = JSON.DeserializeXmlNode("{records:{record:" + grid2Json + "}}");
    
            //array of Dictionaries
            Dictionary<string, string>[] grid1Data = JSON.Deserialize<Dictionary<string, string>[]>(grid1Json);
            Dictionary<string, string>[] grid2Data = JSON.Deserialize<Dictionary<string, string>[]>(grid2Json);
        }
  3. #3
    That didn't seem to work for me, the return from getRowValues on my grid is:

    "Parameter1":"[{\"lst_id\":\"f4bfb666-332a-4601-a8e5-aa11688c94a6\",\"lst_created\":\"2010-12-23T14:40:00\",\"lst_name\":\"New List1\",\"lst_description\":\"List created @ 12/23/2010 2:40:00 PM\",\"lst_date\":\"2011-01-01T00:00:00\"}]"
    The exception thrown is:

    After parsing a value an unexpected character was encountered: :. Line 1, position 30.
    And it is thrown here:

    //XML representation
    XmlNode grid1Xml = JSON.DeserializeXmlNode("{records:{record:" + grid1Json + "}}");
  4. #4
    Hi,

    XML tags cannot contain '_' symbol therefore you cannot deserialize your fields to xml format, please use another format (dictionary or something else)
  5. #5
    Quote Originally Posted by Vladimir View Post
    Hi,

    XML tags cannot contain '_' symbol therefore you cannot deserialize your fields to xml format, please use another format (dictionary or something else)
    So the whole JSON code is useless? Do you have a sample code there?
    Thank you
  6. #6
    Hi,

    Why useless? Just use another format instead XML (like Dictionary in that sample)
  7. #7
    Because that code didn't work as well:

    Error converting value "Parameter1" to type 'System.Collections.Generic.Dictionary`2[System.String,System.String][]'.
  8. #8
    Hi,

    Please provide test sample which we can run localy
  9. #9
    Quote Originally Posted by Vladimir View Post
    Hi,

    Please provide test sample which we can run localy
    Try to use this code:
    Dictionary<string, string>[] grid1Data = JSON.Deserialize<Dictionary<string, string>[]>(ROWVALUESTRING);

    with this string:
    "Parameter1":"[{\"lst_id\":\"f4bfb666-332a-4601-a8e5-aa11688c94a6\",\"lst_created\":\"2010-12-23T14:40:00\",\"lst_name\":\"New List1\",\"lst_description\":\"List created @ 12/23/2010 2:40:00 PM\",\"lst_date\":\"2011-01-01T00:00:00\"}]"
  10. #10
    Hi,

    Why do you try to deserialize such string? 'Parameter1' must be excluded from the string. How do you get that string?
    Please use
    "[{\"lst_id\":\"f4bfb666-332a-4601-a8e5-aa11688c94a6\",\"lst_created\":\"2010-12-23T14:40:00\",\"lst_name\":\"New List1\",\"lst_description\":\"List created @ 12/23/2010 2:40:00 PM\",\"lst_date\":\"2011-01-01T00:00:00\"}]"
Page 1 of 2 12 LastLast

Similar Threads

  1. GridPanel AfterEdit Direct Event and Original Value
    By mtrutledge in forum 1.x Help
    Replies: 4
    Last Post: Aug 21, 2012, 7:42 PM
  2. Gridpanel - Afteredit Event
    By Tbaseflug in forum 1.x Help
    Replies: 1
    Last Post: Feb 09, 2012, 9:22 AM
  3. RowEditor and AfterEdit
    By alexrodi82 in forum 1.x Help
    Replies: 3
    Last Post: Oct 17, 2011, 6:09 PM
  4. Replies: 1
    Last Post: Dec 22, 2010, 3:47 PM
  5. RowEditor - DirectEvents AfterEdit
    By Maia in forum 1.x Help
    Replies: 0
    Last Post: Jul 01, 2010, 12:38 AM

Posting Permissions