May 15, 2012, 1:25 PM
[CLOSED] GridPanel: issue with paging when using DirectMethod
Hi Guys,
I'm using DirectMethod for loading data to Store and I have issue with PagingToolbar. The fist page is displaying correctly. When I click on the Next page button, GridPane shows data from the second page but PagingToolbar shows that I stay on the first page.
My code:
I'm using DirectMethod for loading data to Store and I have issue with PagingToolbar. The fist page is displaying correctly. When I click on the Next page button, GridPane shows data from the second page but PagingToolbar shows that I stay on the first page.
My code:
public static List<Template> GetTestData()
{
List<Template> result = new List<Template>();
for (int i = 0; i < 20; i++)
{
result.Add(new Template() { Id = i, Name = String.Format("Template Name {0}", i), PortfolioLevel = "Yes", Assets = String.Format("Assets Name {0}", i) });
}
return result;
}
[DirectMethod]
public static Paging<Template> GetTemplates(int start, int limit)
{
List<Template> templates = GetTestData();
if ((start + limit) > templates.Count)
{
limit = templates.Count - start;
}
List<Template> rangeTemplates = (start < 0 || limit < 0) ? templates : templates.GetRange(start, limit);
return new Paging<Template>(rangeTemplates, templates.Count);
}
var TemplateGridPageSize = 6;
var templeteListStoreInitializeCalled= false;
function LoadTemplateListStore(start, limit) {
if (!templeteListStoreInitializeCalled) {
Ext.net.DirectMethods.GetTemplates(start, limit,
{
timeout: 300000,
eventMask: { showMask: true, minDelay: 500 },
success: function (result) {
var target = <%= TemplateListStore.ClientID%>;
target.loadData(result, false);
templeteListStoreInitializeCalled = false;
}
});
templeteListStoreInitializeCalled = true;
}
}
var OnTemplateListStorePreLoad = function (store) {
var start, limit;
start = (store.lastOptions.params && store.lastOptions.params.start) || 0;
limit = (store.lastOptions.params && store.lastOptions.params.limit) || TemplateGridPageSize;
LoadTemplateListStore(start, limit);
}
<ext:Store ID="TemplateListStore" runat="server" RemotePaging="true" AutoLoad="true">
<Reader>
<ext:JsonReader Root="Data" TotalProperty="TotalRecords">
<Fields>
<ext:RecordField Name="Id" />
<ext:RecordField Name="Name" />
<ext:RecordField Name="PortfolioLevel" />
<ext:RecordField Name="Assets" Mapping="Assets" />
</Fields>
</ext:JsonReader>
</Reader>
<Proxy>
<ext:HttpProxy />
</Proxy>
<Listeners>
<BeforeLoad fn="OnTemplateListStorePreLoad" />
</Listeners>
<AutoLoadParams>
<ext:Parameter Name="start" Value="={0}" />
<ext:Parameter Name="limit" Value="={6}" />
</AutoLoadParams>
</ext:Store>
<ext:GridPanel ID="TemplateListGrid" StoreID="TemplateListStore" Collapsible="false" TitleCollapse="true"
Frame="true" StripeRows="true" HideHeaders="false" Height="300" Border="true" runat="server" >
<ColumnModel ID="cmTemplateListGrid" runat="server">
<Columns>
<ext:Column DataIndex="Name" Header="Template Name" Tooltip="Template Name" Width="300"> </ext:Column>
<ext:Column DataIndex="PortfolioLevel" Header="Portfolio Level Template" Tooltip="Portfolio Level Template" Width="100"><Renderer/></ext:Column>
<ext:Column DataIndex="Assets" Header="Associated Assets" Tooltip="Associated Assets" Width="150"><Renderer /></ext:Column>
</Columns>
</ColumnModel>
<LoadMask ShowMask="true" />
<View>
<ext:GridView DeferEmptyText="false" />
</View>
<SelectionModel>
<ext:RowSelectionModel ID="TemplateListRowSelectionModel" runat="server"/>
</SelectionModel>
<BottomBar>
<ext:PagingToolbar ID="TemplateListPagingToolbar" runat="server" StoreID="TemplateListStore" PageSize="6" DisplayInfo="true" DisplayMsg="Displaying templates {0} - {1} of {2}" >
</ext:PagingToolbar>
</BottomBar>
</ext:GridPanel>
Thank you.
Last edited by Daniil; May 16, 2012 at 10:23 AM.
Reason: [CLOSED]