Nov 10, 2010, 1:20 PM
[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:
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=" " 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]