[CLOSED] Persist selected checkboxes across paginated grid

  1. #1

    [CLOSED] Persist selected checkboxes across paginated grid

    I reviewed a bunch of threads on this but nothing seems to work properly. I want to stay in the client side and not utilize the code behind. I assume that the Before on the button can call UpdateSelection somehow but i am not 100% of the ordering.

    The end goal is that if i select items across multiple pages, when i press the button, all selected items are sent. I have gotten the code below to work (json is passed to controller) but it only works on current page.

    Thanks!

    My grid is below:

                    <ext:GridPanel 
                        ID="GridPanelSearchResults" 
                        runat="server" 
                        Frame="true" 
                        AutoHeight="true"
                        Hidden="true"
                        MaxHeight="400"
                        X="0"
                        Y="0"
                        AutoWidth="true"
                        AutoRender="false">
                        <Store>
                            <ext:Store ID="StoreSearchResults" runat="server" RemoteSort="false" AutoLoad="false">
                                <Proxy>
                                    <ext:HttpProxy Method="GET" Url="/Search/FindData" />
                                </Proxy>
                                <BaseParams>
                                    <ext:Parameter Name="start" Value="={0}" />
                                    <ext:Parameter Name="limit" Value="={25}" />
                                </BaseParams>
                                <Reader>
                                    <ext:JsonReader Root="data" IDProperty="id" TotalProperty="total">
                                        <Fields>
                                            <ext:RecordField Name="id" Type="Int" />
                                            <ext:RecordField Name="firstName" Type="String" />
                                            <ext:RecordField Name="lastName" Type="String" />
                                        </Fields>
                                    </ext:JsonReader>
                                </Reader>
                                <SortInfo Field="id" Direction="DESC" />
                            </ext:Store>
                        </Store>
                        <ColumnModel ID="ColumnModelResults" runat="server">
                            <Columns>
                                <ext:Column ColumnID="id" Header="Id" DataIndex="id" Width="50" Sortable="true" Hidden="true" />
                                <ext:Column ColumnID="firstName" Header="First Name" DataIndex="firstName" Width="100"  Sortable="true" />
                                <ext:Column ColumnID="lastName" Header="Last Name" DataIndex="lastName" Width="100"  Sortable="true" />
                            </Columns>
                        </ColumnModel>
                        <SelectionModel >
                            <ext:CheckboxSelectionModel runat="server" />
                        </SelectionModel>                            
                        <BottomBar>
                            <ext:PagingToolbar ID="PagingToolbar" 
                                runat="server" 
                                PageSize="25"
                                DisplayInfo="true" 
                                DisplayMsg="Displaying results {0} - {1} of {2}" 
                                EmptyMsg="No results to display" 
                                />
                        </BottomBar>
                        <LoadMask ShowMask="true" />
                    </ext:GridPanel>
        
       <ext:Button ID="ButtonUtilize" runat="server" Text="Utilize" Icon="Find">
        <DirectEvents>
         <Click 
          Url="/Assignment/Utilize/" 
          CleanRequest="true" >
          <ExtraParams>
           <ext:Parameter Name="ids" Value="Ext.encode(#{GridPanelSearchResults}.getRowsValues({selectedOnly : true}))" Mode="Raw" />
          </ExtraParams>
         </Click>
        </DirectEvents>
       </ext:Button>
    Last edited by Daniil; Oct 25, 2012 at 5:17 AM. Reason: [CLOSED]
  2. #2
    Hi @Z,

    All selected rows ids are stored in the GridPanel's selectedIds property.
    #{GridPanel1}.selectedIds
    It stores ids and indexes only.
  3. #3

    Persist selected checkboxes across paginated grid

    That worked nicely.

    For anyone else that needs a C# object use this code:

                    JavaScriptSerializer serializer = new JavaScriptSerializer();
                    Dictionary<string, Dictionary<string,object>> obj = serializer.Deserialize<Dictionary<string, Dictionary<string,object>>>(selectedEmployeeIds);
    /Z

    Quote Originally Posted by Daniil View Post
    Hi @Z,

    All selected rows ids are stored in the GridPanel's selectedIds property.
    #{GridPanel1}.selectedIds
    It stores ids and indexes only.
  4. #4
    Another way is getting required data from "selectedIds" on client.

    E.g. you could retrieve only ids putting them into an array. Then you could deserialize it to an array or list on server.
  5. #5
    Quote Originally Posted by Daniil View Post
    All selected rows ids are stored in the GridPanel's selectedIds property.
    #{GridPanel1}.selectedIds
    It stores ids and indexes only.
    I forgot to clarify that the getRowValues method can retrieve all selected rows with local paging only.

Similar Threads

  1. Persist selection with pagination
    By testix in forum 1.x Help
    Replies: 6
    Last Post: May 21, 2014, 12:35 PM
  2. Gantt control how to persist data
    By glenh in forum 2.x Help
    Replies: 0
    Last Post: Sep 13, 2012, 2:01 AM
  3. Replies: 3
    Last Post: Dec 26, 2011, 1:32 PM
  4. [CLOSED] Possible bug: Viewstate doesn't persist
    By drgw74 in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Feb 03, 2009, 5:00 AM
  5. [CLOSED] Persist selection over pagination
    By methode in forum 1.x Legacy Premium Help
    Replies: 7
    Last Post: Nov 30, 2008, 11:38 AM

Posting Permissions