PDA

View Full Version : [CLOSED] MVC Grid Problem Paging



adelaney
May 16, 2012, 2:34 PM
First, I may be doing this completely differently than I should as I am not as familiar with Ext as other control sets, so please bear with me.

I have a grid where I want to, on the fly, repopulate the grid based on the parameter passed in the URL:
(e.g. URL - /_GetTeams/1, /_GetTeams/2 - etc. Please note that the parameter passed in is an EMPLOYEE ID, not a team ID.) In order to make this work, I have set up my grid's store proxy API to have a default read like this:


With prxy
.API.Read = Url.Content("~/Assignments/_GetTeams/") + MvcApplication.CurrentApplicationUser.EmployeeID.T oString()
End With

I also have pagination configured for my grid:

.BottomBar(Sub(footer)
Dim pager As New Ext.Net.PagingToolbar()
With pager
.AutoDataBind=True
End With
footer.Add(pager)
End Sub)

Now, my initial load of the grid is autoloaded. However, I have radio buttons at the top of the page which allow for the changing of the view (the default is "My Teams"). Some options are "My Teams," "All Teams," "My Direct Reports" - etc. and my goal is not to completely post-back the whole page (hence the proxy).

In order to accomplish this, I have events which capture the selected radio and switch off the value, and then the script reloads the grid store:

function RebindGrid(e) {
var linkRef = "/Assignments/_GetTeams/" + e.toString();
App.TeamGrid.store.proxy.api.read=linkRef;
App.TeamGrid.store.load();
}

The data being returned is correct and binds to the grind 100% correctly However, pagination does not work. The toolbar has the correct number of pages and total. The toolbar will even "paginate," (page number increments) but every row of data is returned every time. I didn't catch it for a while because most results are only 1 page, but "All Teams" is long. I am completely fine with returning all the data an doing client-side pagination, but I am open to handling it server-side if that is how it must be handled (the post definitely has the pagination info in it: http://server/Assignments/_GetTeams/?_dc=1337176904679&page=1&start=0&limit=15&sort=%5B%7B%22property%22%3A%22DrafterEmployeeID%2 2%2C%22direction%22%3A%22ASC%22%7D%5D). However, most importantly, I am trying to figure out how the correct way to handle this scenario.

Any help is appreciated.

Daniil
May 16, 2012, 7:33 PM
Hi,



I have a grid where I want to, on the fly, repopulate the grid based on the parameter passed in the URL:
(e.g. URL - /_GetTeams/1, /_GetTeams/2 - etc. Please note that the parameter passed in is an EMPLOYEE ID, not a team ID.) In order to make this work, I have set up my grid's store proxy API to have a default read like this:


With prxy
.API.Read = Url.Content("~/Assignments/_GetTeams/") + MvcApplication.CurrentApplicationUser.EmployeeID.T oString()
End With


To set up parameters for actions I would use StoreParameter with a respective Action.

<ext:Store runat="server">
...
<Parameters>
<ext:StoreParameter Action="Read" Name="test" Value="hello!" Mode="Value" />
</Parameters>
</ext:Store>

The list of possible Actions: Read, Create, Update, Destroy.


the post definitely has the pagination info in it: http://server/Assignments/_GetTeams/?_dc=1337176904679&page=1&start=0&limit=15&sort=%5B%7B%22property%22%3A%22DrafterEmployeeID%2 2%2C%22direction%22%3A%22ASC%22%7D%5D). However, most importantly, I am trying to figure out how the correct way to handle this scenario.

I can't see the parameter "e.toString()" in that URL.

var linkRef = "/Assignments/_GetTeams/" + e.toString();
App.TeamGrid.store.proxy.api.read=linkRef;

So, I'm not sure it's a problem request when you are facing broken paging. Are you sure?

What is the response of the problem request?

Do you analyse the start and limit parameters on server side to return a respective data for a current page or do you return all data?

adelaney
May 16, 2012, 7:48 PM
The URL I provided has a "null" parameter - which will return all Teams. Other examples are something like:


...(e.g. URL - /_GetTeams/1, /_GetTeams/2 - etc...

which will return teams for employee1 and teams for employee2 - respectively.

Right now, yes, I am returning all the data. As stated before, most of the result sets are really small. However, there are a few that are a several dozens of rows. (However, in the future, for large grids, I will use the Parameters collection)

Again, the data is coming back from the post and binding correctly - I have 121 rows. Additionally, the pager at limit of 20 comes back with 7 pages and the first page reports 1-20 or 121 - which is also correct, clicking a navigation button cause a repost to the URL (which brings back all the records again).

Daniil
May 16, 2012, 7:55 PM
Right now, yes, I am returning all the data. As stated before, most of the result sets are really small.

In the case with remote paging you should return from server a data for a current page only analyzing the "start" and "limit" parameters.

Please note there is remote paging be default if you configure the Store with any type of Proxy.

You can set up

RemotePaging="false"
for the Store if you don't want to deal with remote paging for now.