I am using a function to change a grids datasource, but it seems that after attaching the new datasource and refreshing, the paging elements do not refresh/adjust to the new datasource?
Does anyone have an idea?
The code i use:
10 Answers, 1 is accepted
Solved my own problem. I needed to specify the dataSource.schema.total json path to extract the total number of records (using django + tastypie). I found this by RTFM.
Unfortunately it didn't solve my problem. :(
I RTFM a bit and added me an anonymous function for the total attribtue of the schema (nothing else added, see code above):
it logs "38" to the console, the grid shows 10 items (which is correct since it's the value of the pageSize attribue), yet the paging row only contains links to the first (single) page...
The call to .refresh() in the event handler of the "change" event in my datasource makes sure that the first page is displayed... (without it the grid stays empty)
But the pager at the bottom of the grid still only shows 1 page even tho there should be 4.
Does calling refresh() update the pager for you??
Seems to be painful to display a list of json objects with ajax..
i'm going to take the Twitter sample now and try again, I see that they approach it differently to what I did.
trick set the datasource only once,
then call datasource.read(whateverDataYouNeedToSend);
works like a charm..
Thanks for posting your solution. As a matter of fact i did manage to get things to work in yet another way (by stumbling on it by accident).
I am fetching the result of the call to datasource.read() via ajax and handing it to the data() function of the datasource.
Here the function i use:
Note: above function is bound to the change event of a <select>.
I guess either method might be useful for someone out there looking at the same challenge.
Thanks again Brian!
// set the page active with the current page