Hi
How do I get the PageIndex of a PagingToolbar, this was possible in older version, but I can't find the property any more?
Regards
Mikael
Printable View
Hi
How do I get the PageIndex of a PagingToolbar, this was possible in older version, but I can't find the property any more?
Regards
Mikael
Hello @Jurke!
Do you mean the current page the pager is in? Or is it something else related to the page?
If that's the current page, you should get it off the related store instead. If you already have the paging toolbar handy in your code and don't want to go thru the trouble to get the store off its grid, you can just call paging toolbar's getStore() method. It is not private, so you are guaranteed at least a breaking change notice if this ever changes in the future.
Once you have the store, you can then get the page by its currentPage property.
If you really, really want to get the current page (and other page data), you can use the paging toolbar's private getPageData() method. It will return an object with acurrentPage
member which you can use and should match the store's.
I am assuming you want to get the page from client-side. If you have a specific condition, it always helps to present a test case or an Ext.NET Examples's sample pointing then where exactly in the code you need to get the information. In some circumstances, from server-side, you need to "post back" the value you need, so there's little I can guess from the inquiry you currently presented.
Hope this helps!
Hi
Sorry for being unclear, in the old code I could the the current page number in code behind with this property
PagingToolbar1.PageIndex. But that does not work any more. Is it possible to get the current page number in code behind in a DirectEvent?
Regards
Mikael
Hello Mikael,
Okay, I got it. I found one example that used it, and now we can see how it does the same task. Please compare these two examples:
- Form > Miscellaneous > Edit_Form_View in Ext.NET Examples 1
- Form > Miscellaneous > Edit_Form_View in Ext.NET Examples 5
Check how theDeleteClick()
code-behind handler changed. I believe you may be able to apply the same change in your version.
Hope this helps!
Hi
I can't implement this because in this case there is only one row, so the index of the datasource will be the same as pageIndex. I my case I have a Grid with several rows, so one page contains x rows.
Maybe there is another way to do what I want. I want to cycle the pages automatically in the Gridpanel, this page is for showing data on a TV-screen, and if there is more than one page it should cycle them through.
I did this manually with a timer and with the PageIndex in the old Ext. version.
Regards
Mikael
Hello Mikael,
Can't you think a test case that could highlight how the data view looks like, and describe what you need to achieve in it, so we may better aid you in the issue?
By the description you provided, it seems best rely on client-side code instead of always calling server just to advance a page in the list of entries, so instead of guesses I believe we would best switch to sample case, to allow us to provide you better advice.
Maybe this example would be a good starting place: DataView > Basic > With_Paging
Looking forward to your follow-up!
Hi
I manage to solve how to get the property pageIndex from the PagingToolbar, instead of getting it server side I got it from the client and then passed it to the server (DirectEvent).
Client
ServerCode:<Update OnEvent="ChangePage">
<ExtraParams>
<ext:Parameter Name="numberOfRows" Value="#{gpFelrapporter}.getStore().getTotalCount()" Mode="Raw" />
<ext:Parameter Name="pageSize" Value="#{gpFelrapporter}.getStore().pageSize" Mode="Raw" />
<ext:Parameter Name="pageIndex" Value="#{PagingToolbar1}.getPageData().currentPage" Mode="Raw" />
</ExtraParams>
</Update>
RegardsCode:public void ChangePage(object sender, DirectEventArgs e)
{
int numberOfRows = GlobalFunctions.TryParseInt(e.ExtraParams["numberOfRows"].ToString());
int pageSize = GlobalFunctions.TryParseInt(e.ExtraParams["pageSize"].ToString());
int pageIndex = GlobalFunctions.TryParseInt(e.ExtraParams["pageIndex"].ToString());
}
Mikael
Hello agian Mikael!
Glad you found a solution that works for you, and thanks for sharing it. Can't really say much about it, it works on your side and that's what matters, I guess.
Something that you may want to consider is changing your pageIndex parameter to use documented and supported public interface from Sencha, that is guaranteed, worst case, to be disclosed in a breaking change if it ever changes.
In your case you rely on private, and barely documented Ext.toolbar.Paging.getPageData() where you could just favor documented Ext.data.Store.currentPage
That said, I believe your code where it reads:
it should instead readCode:#{PagingToolbar1}.getPageData().currentPage
Just like the other two extra parameters.Code:#{gpFelrapporter}.getStore().currentPage
Hope this helps!
EDIT: to clarify, relying on non-documented private (or just non-documented) methods from Ext JS / Ext.NET may mean future headache as the references may be changed or even removed, renamed, without any notice.
Great input, thanks! That row was from the old code, and was something one of you gurus (maybe Vladimir) dug up for me many years ago.
I made the change to the code and it works great!
Regards
Mikael
Hello, and yes, at some point I believe this was the way to go but, through experience, and now that we have an "officially supported" way for getting the information, we should rely and migrate to it whenever possible.
This may never change in the future. But if it does, we will at least be able to avoid hitting the wall with undisclosed changes to the API.
I believe we are done here as well, right? I'll mark it as 'closed' but feel free to post here if you have anything to add to the thread.