How to get all rows of a gridpanel

  1. #1

    How to get all rows of a gridpanel

    How do i get the value of a specific column in each and every row of a gridpanel?

    Thanks

  2. #2

    RE: How to get all rows of a gridpanel

    I am sure there are many ways to do this. I am sending it back on a button with extra parameters but you can also wire up the store 'submit' as well.

    Example 1:
    <ext:Button ID="BtnAutoSave" Text="Save" Icon="Disk" IDMode="Static" Hidden="true">
                                                               <AjaxEvents>
                                                                    <Click 
                                                                        OnEvent="Submit_TCGridPanels" 
                                                                        Timeout="20000"
                                                                        Method="POST"
                                                                        Before="msgEvent('AutoSaved!');"
                                                                        ViewStateMode="Include">
                                                                        <ExtraParams>
                                                                            <ext:Parameter Name="EventAction" Value="AutoSave" />
                                                                            <ext:Parameter Name="Week1" Value="Ext.encode(FullTimecard1_TC1_TimeCardGrid.getRowsValues(false))" Mode="Raw" />
                                                                            <ext:Parameter Name="Week2" Value="Ext.encode(FullTimecard1_TC2_TimeCardGrid.getRowsValues(false))" Mode="Raw" />
                                                                        </ExtraParams>
                                                                    </Click>
                                                                </AjaxEvents>
                                                            </ext:Button>

    Sometimes its more straightforward to just have the store call back with the information on submit:
    <ext:Store 
        ID="TCStore" 
        runat="server"
        OnSubmitData="TCStore_Submit"
        UseIdConfirmation="true"
        OnRefreshData="TCStore_RefreshData">
        <Proxy>
            <ext:DataSourceProxy />
        </Proxy>
        <Reader>
            <ext:JsonReader>
                <Fields>
                    <ext:RecordField Name="Id"              Type="Auto"></ext:RecordField>
                    <ext:RecordField Name="LineNumber"      Type="String"></ext:RecordField>
                    <ext:RecordField Name="PayType"         Type="String"></ext:RecordField>

    Then in your code behind:
    protected void TCStore_Submit(object sender, StoreSubmitDataEventArgs e)
    {
    ...
    }


  3. #3

    RE: How to get all rows of a gridpanel

    Here is the code behind wire up in my first example: What I do is create a struct or class that represents the data from the store. I can then use the JSON.Deserialize and pass in the raw json and return an array of those structs that represent the data from the grid in my typecasted structures making it easy to update the database or do what ever with.

    string jsonForEvent = e.ExtraParams["EventAction"];
                string jsonForWeek1 = e.ExtraParams["Week1"];
                string jsonForWeek2 = e.ExtraParams["Week2"];
    
    
                TSLineHandler[] week1lines = null;
                TSLineHandler[] week2lines = null;
                try
                {
                    week1lines = (TSLineHandler[])JSON.Deserialize<TSLineHandler[]>(jsonForWeek1);
                    week2lines = (TSLineHandler[])JSON.Deserialize<TSLineHandler[]>(jsonForWeek2);
                }
                catch (Exception ex)
                {
                    this.ScriptManager1.AddScript("msgEvent('Ugh!  Technical problem');");
                    return;
                }
    
    
                if ((week1lines == null) || (week2lines == null))
                {
                    this.ScriptManager1.AddScript(
                        "Ext.getCmp('ApplicationMessageLabel').getEl().update('{0}');",
                        "Aw snap!  Some technical error has occured."
                    );
                    return;
                }
    ...

Similar Threads

  1. [CLOSED] GridPanel.Rows.Changing Background Color of Rows
    By supera in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Mar 01, 2012, 5:18 PM
  2. Replies: 1
    Last Post: Oct 13, 2010, 11:09 PM
  3. gridpanel columns and rows
    By gpcontreras in forum 1.x Help
    Replies: 1
    Last Post: Feb 02, 2010, 10:26 PM
  4. Rows of GridPanel
    By egof in forum 1.x Help
    Replies: 4
    Last Post: Oct 14, 2008, 3:51 PM
  5. Getting Rows of GridPanel
    By egof in forum 1.x Help
    Replies: 0
    Last Post: Oct 13, 2008, 9:22 PM

Posting Permissions