[CLOSED] Problem when paging gridpanel in AjaxEvent

  1. #1

    [CLOSED] Problem when paging gridpanel in AjaxEvent

    Hi,

    I'm having some problems when paging a gridpanel. When the data is loaded during an AjaxEvent the GridPanel is not paging.
    When the Page is loaded the first time (Page.IsPostBack is false) the paging is correct, but when I click the button to reload the gridpanel all records are displayed.

    NOTE: This error does not occurs if you click a move page button (previous or next) and click the Reload Grid button. The error will appear if you click the Reload Grid button after the Page is loaded the first time.

    Follows the example code:

    <%@ Page Language="C#" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <script runat="server">
        
        public class Test
        {
            public string Document { get; set; }
            public DateTime? Date { get; set; }
            public int ID { get; set; }
            public string Guid { get; set; }
            public double? Value { get; set; }
        }
    
        [DirectMethod]
        public void LoadGrid()
        {
            System.Collections.Generic.List<Test> list = new System.Collections.Generic.List<Test>();
    
            string doc = null;
            Random r = new Random();
    
            for (int i = 0; i < 100; i++)
            {
                if (i % 10 == 0)
                    doc = "ABC-123456";
                else if (i % 8 == 0)
                    doc = "SFAE-ERWWE";
                else if (i % 5 == 0)
                    doc = "56RGHGF3454";
                else if (i % 3 == 0)
                    doc = "RGSDWD-155";
                else if (i % 2 == 0)
                    doc = "AASFAERAR4";
                else
                    doc = "QWERQRT-44";
    
                list.Add(new Test()
                {
                    ID = i,
                    Document = doc,
                    Date = DateTime.Today,
                    Guid = Guid.NewGuid().ToString(),
                    Value = 1000 * r.NextDouble()
                });
            }
    
            storeTest.DataSource = list;
            storeTest.DataBind();
        }
        
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            
            btnReload.DirectEvents.Click.Event += delegate(object sender, DirectEventArgs e2) { this.LoadGrid(); };
            
            if (!Page.IsPostBack)
            {
                //ExtNet.Call("loadGrid");
                this.LoadGrid();
            }
        }
    
        
        
    </script>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Untitled Page</title>
    <script type="text/javascript">
    function Aprov(command, groupId, records)
    {
        for(var i=0;i< records.length;i++)
        {
            if(command == 'aprov-yes')
                records[i].set('Aprov', 'Yes');
            else
                records[i].set('Aprov', 'No');
    
            records[i].commit();
        }
    }
    
    function loadGrid()
    {
        Ext.net.DirectMethods.LoadGrid();
    }
    
    </script>
    </head>
    <body>
        <form id="form1" runat="server">
            <ext:ResourceManager runat="server" />
            
            <ext:Button ID="btnReload" runat="server" Text="Reload Grid" />
            
            <ext:GridPanel ID="grdTest" runat="server" EnableViewState="false" Width="900" Height="480" Border="true"
                    ColumnLines="true" RegionMaxHeight="100" RowHeight="1" Frame="true" >
                <Store>
                    <ext:Store ID="storeTest" runat="server" GroupField="Document">
                        <Reader>
                            <ext:JsonReader>
                                <Fields>
                                    <ext:RecordField Name="Document" Type="String" />
                                    <ext:RecordField Name="Date" Type="Date" />
                                    <ext:RecordField Name="ID" Type="Int" />
                                    <ext:RecordField Name="Guid" Type="String" />
                                    <ext:RecordField Name="Value" Type="Float" />
                                    <ext:RecordField Name="Aprov" Type="String" />
                                    <ext:RecordField Name="Notes" Type="String" />
                                </Fields>
                            </ext:JsonReader>
                        </Reader>
                    </ext:Store>
                </Store>
                <ColumnModel runat="server">
                    <Columns>
                        <ext:GroupingSummaryColumn DataIndex="Document" Header="Document" Groupable="true" SummaryType="None">
                            <Renderer Handler="return 'DOCUMENT  >>  ' + record.data.Document;" />
                        </ext:GroupingSummaryColumn>
                        
                        <ext:Column Header="Document" DataIndex="Document" Width="200" />
                        <ext:DateColumn Header="Date" DataIndex="Date" Width="70" />
                        <ext:Column Header="ID" DataIndex="ID" Width="30" />
                        <ext:Column Header="GUID" DataIndex="Guid" Width="140" />
                        <ext:NumberColumn Header="Value" DataIndex="Value" Width="75" Align="Right" >
                            <Renderer Fn="renderValue" Handler="alert('');"  />
                        </ext:NumberColumn>
                        <ext:Column Header="Aproved" DataIndex="Aprov" Width="40">
                            <Editor>
                                <ext:ComboBox runat="server" Editable="false" ForceSelection="false">
                                    <Items>
                                        <ext:ListItem Text="&nbsp;" Value="" />    
                                        <ext:ListItem Text="Yes" Value="Yes" />
                                        <ext:ListItem Text="No" Value="No" />
                                    </Items>
                                </ext:ComboBox>
                            </Editor>
                        </ext:Column>
                        <ext:Column Header="Notes" DataIndex="Notes" >
                            <Editor>
                                <ext:TextField runat="server" />
                            </Editor>
                        </ext:Column>
                        
                        <ext:CommandColumn Hidden="true" >
                            <GroupCommands>
                                <ext:CommandFill />
                                <ext:GridCommand Text="Aprov" StandOut="false">
                                    <Menu>
                                        <Items>
                                            <ext:MenuCommand CommandName="aprov-yes" Text="Yes" />
                                            <ext:MenuCommand CommandName="aprov-no" Text="No" />
                                        </Items>
                                    </Menu>
                                </ext:GridCommand>
                            </GroupCommands>
                        </ext:CommandColumn>
                        
                    </Columns>
                </ColumnModel>
                
                <Listeners>
                    <GroupCommand Handler="Aprov(command, groupId, records);" />
                </Listeners>
                
                <BottomBar>
                        <ext:PagingToolbar runat="server" PageSize="30" HideRefresh="True" />
                </BottomBar>
                <LoadMask ShowMask="true" />
                <View>
                    <ext:GroupingView runat="server" EnableViewState="false" 
                            HideGroupedColumn="true" EnableRowBody="true" ForceFit="true" 
                            MarkDirty="false" ShowGroupName="false" EnableNoGroups="true" />
                </View>
                <Plugins>
                    <ext:EditableGrid ID="EditableGrid1"  runat="server" />
                </Plugins>
                
                <SelectionModel>
                    <ext:CellSelectionModel ID="CellSelectionModel1" runat="server" EnableViewState="false">
                        <Listeners>
                            <CellSelect Handler=" if(colIndex==4){ Ext.Msg.alert('GUID',item.selection.record.data.Guid);}" />
                        </Listeners>
                    </ext:CellSelectionModel>
                </SelectionModel>
            </ext:GridPanel>    
        </form>
    </body>
    </html>
    Last edited by Daniil; Nov 11, 2010 at 11:31 AM. Reason: [CLOSED]
  2. #2
    Hi,

    Please set the following AutoLoadParams for the Store.

    Example
    <ext:Store ID="storeTest" runat="server" GroupField="Document">    
        <AutoLoadParams>
            <ext:Parameter Name="start" Value="0" Mode="Raw" />
            <ext:Parameter Name="limit" Value="30" Mode="Raw" />
        </AutoLoadParams>
        ...
    </ext:Store>
  3. #3
    Hi Daniil,

    In my case, when selecting a row of the gridpanel happens something similar (all records of all pages are loaded in the first page).
    But this only happens first time I select a row. When I forward and I backward the pages, and then I select a row, that does not happen again.

    I tested your solution but doesn´t work.

    Any other idea?
    Last edited by walle; Nov 10, 2010 at 4:06 PM.
  4. #4
    Hi,

    I am unsure what may be wrong. To say something concrete I need to have a look at your code.
  5. #5
    Hi Daniil,

    Sorry, your code works fine.

    Thanks a lot.
    Last edited by walle; Nov 10, 2010 at 8:06 PM.
  6. #6
    Hi,

    Thank for the notifying.

Similar Threads

  1. GridPanel Remote Paging Problem
    By zhangjiagege in forum 1.x Help
    Replies: 6
    Last Post: Nov 22, 2011, 8:17 AM
  2. [CLOSED] CheckBoxSelectionModel with paging in Gridpanel Problem
    By webppl in forum 1.x Legacy Premium Help
    Replies: 5
    Last Post: May 30, 2011, 9:08 AM
  3. Gridpanel Paging and Filter Problem.
    By Ganesh3.shirsath in forum 1.x Help
    Replies: 0
    Last Post: Feb 15, 2011, 7:16 AM
  4. wired problem in gridpanel paging
    By joydeepsen in forum 1.x Help
    Replies: 5
    Last Post: Jun 06, 2009, 6:40 AM
  5. gridpanel getSelections problem with paging
    By Lex in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Sep 30, 2008, 1:30 PM

Tags for this Thread

Posting Permissions