[CLOSED] Dynamically Changing GridPanel Paging in DirectEvent

  1. #1

    [CLOSED] Dynamically Changing GridPanel Paging in DirectEvent

    I have a page with a ComboBox and a GridPanel. The ComboBox allows the user to select a search type and the GridPanel displays the search results. Different searches will return different numbers of records and so I'd like to configure the GridPanel paging accordingly. If the search returns say 100 records or less I want to use local paging. For more than 100 records I want to use remote paging. Is it possible to change the GridPanel paging dynamically?

    The following code illustrates what I am trying to do; i.e. Add/Remove the PageProxy of the GridPanel's underlying store, based on the number of records. However it is not working - the GridPanel always retains its previous paging configuration and does not use the new configuration.


    
        Protected Sub lstSearchType_Select(ByVal sender As Object, ByVal e As DirectEventArgs)
    
            Dim searchType As Integer = DirectCast(sender, Ext.Net.ComboBox).SelectedItem.Value
            Dim oCustomers As New Customers(searchType)
    
            If oCustomers.Count <= 100 Then
    
                '   Use local paging
                If stoCustomer.Proxy.Count > 0 Then
                    stoCustomer.Proxy.RemoveAt(0)
                End If
    
                stoCustomer.DataSource = oCustomers
                stoCustomer.DataBind()
    
            Else
    
                '   Use remote paging
                If stoCustomer.Proxy.Count = 0 Then
                    stoCustomer.Proxy.Add(New Ext.Net.PageProxy())
                End If
    
            End If
    
        End Sub
    Last edited by Daniil; Jun 27, 2011 at 12:44 PM. Reason: [CLOSED]
  2. #2
    Hi,

     stoCustomer.Proxy.Add(New Ext.Net.PageProxy())
    and
    stoCustomer.Proxy.RemoveAt(0)
    doesn't make any sense during DirectEvent.

    I can suggest you to define two stores and re-render the GridPanel when you'd like to change paging type.

    Example
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <%@ Import Namespace="System.Collections.Generic" %>
    
    <script runat="server">
        public List<object> MyData = new List<object> 
        { 
            new { test = "test1" },
            new { test = "test2" },
            new { test = "test3" },
            new { test = "test4" },
            new { test = "test5" },
            new { test = "test6" },
            new { test = "test7" },
            new { test = "test8" },
            new { test = "test9" }
        };
    
        protected void Store_RefreshData(object sender, StoreRefreshDataEventArgs e)
        {
            List<object> data = this.MyData;
            var limit = e.Limit;
            if ((e.Start + e.Limit) > data.Count)
            {
                limit = data.Count - e.Start;
            }
            List<object> rangeData = (e.Start < 0 || limit < 0) ? data : data.GetRange(e.Start, limit);
            e.Total = data.Count;
            (sender as Store).DataSource = rangeData;
        }
    
        protected void SetLocalPaging(object sender, DirectEventArgs e)
        {
            Store store = this.Store1;
            this.GridPanel1.StoreID = store.ID;
            store.DataSource = MyData;
            store.DataBind();
            this.GridPanel1.Render();
        }
    
        protected void SetRemotePaging(object sender, DirectEventArgs e)
        {
            Store store = this.Store2;        
            this.GridPanel1.StoreID = store.ID;        
            this.GridPanel1.Render();
        }
    </script>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Ext.Net Example</title>
    </head>
    <body>
        <form runat="server">
        <ext:ResourceManager runat="server" />
        <ext:Store ID="Store1" runat="server">
            <Reader>
                <ext:JsonReader>
                    <Fields>
                        <ext:RecordField Name="test" />
                    </Fields>
                </ext:JsonReader>
            </Reader>
            <AutoLoadParams>
                <ext:Parameter Name="start" Value="0" Mode="Raw" />
                <ext:Parameter Name="limit" Value="3" Mode="Raw" />
            </AutoLoadParams>
        </ext:Store>
        <ext:Store ID="Store2" runat="server" OnRefreshData="Store_RefreshData">
            <Proxy>
                <ext:PageProxy />
            </Proxy>
            <Reader>
                <ext:JsonReader>
                    <Fields>
                        <ext:RecordField Name="test" />
                    </Fields>
                </ext:JsonReader>
            </Reader>
            <BaseParams>
                <ext:Parameter Name="start" Value="0" Mode="Raw" />
                <ext:Parameter Name="limit" Value="3" Mode="Raw" />
            </BaseParams>
        </ext:Store>
        <ext:Container runat="server" AutoHeight="true">
            <Items>
                <ext:GridPanel 
                    ID="GridPanel1" 
                    runat="server" 
                    StoreID="Store1" 
                    AutoHeight="true">
                    <ColumnModel runat="server">
                        <Columns>
                            <ext:Column Header="Test" DataIndex="test" />
                        </Columns>
                    </ColumnModel>
                    <BottomBar>
                        <ext:PagingToolbar runat="server" PageSize="3" />
                    </BottomBar>
                </ext:GridPanel>
            </Items>
        </ext:Container>
        <ext:Button runat="server" Text="Set local paging" OnDirectClick="SetLocalPaging" />
        <ext:Button runat="server" Text="Set remote paging" OnDirectClick="SetRemotePaging" />
        </form>
    </body>
    </html>
    Also you can be interested in this example:
    https://examples1.ext.net/#/GridPane...h_Remote_Data/

Similar Threads

  1. Replies: 3
    Last Post: Feb 21, 2012, 6:40 AM
  2. Replies: 0
    Last Post: Dec 22, 2010, 7:33 AM
  3. [CLOSED] GridPanel paging after databind during DirectEvent
    By jmcantrell in forum 1.x Legacy Premium Help
    Replies: 6
    Last Post: Jul 15, 2010, 10:04 AM
  4. [CLOSED] Changing inputtextmask Mask dynamically
    By Hari_CSC in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: May 01, 2010, 2:57 AM
  5. [CLOSED] Dynamically changing control hierarchy
    By randy85253 in forum 1.x Legacy Premium Help
    Replies: 6
    Last Post: Dec 13, 2009, 4:57 PM

Tags for this Thread

Posting Permissions