WebGrid and Custom Paging with Custom Objects

4 replies. Last post: January 7, 2013 6:09 AM by Hans Kristian
Tags :
  • (None)
  • New Discussion
  • New Question
  • New Product Feedback
Steve ExtendMember

Hi,

I am new to WebGrid development and I have been assigned a project that like all IT projects must be completed 2 weeks ago. I need to implement custom paging and I was wondering if anyone had any pointers. I've looked at the docs and tutorials and I'm not 100% sure how to handle it.

 

We have a framework that has the following API call:

int customerId = 67; //This would be specified by a param in the query string of a Url.
int pageIndex = 3;
int pageSize = 25;
 
Users selectedUsers = Users.GetUsers(customerId, pageIndex, pageSize);
int maxPageIndex = selectedUsers.MaxPageIndex; //This is the maximum page index that should be shown on the grid

This returns all users for a given customer, page index and page size. In the same call it also returns the maximum no of pages.



This is an n-tiered and layers solution and the GetUsers call makes a special WCF service call to a remote workflow engine. This WCF Workflow Engine can be located anywhere in the world. The only data we have is the Users class as shown above.



I have read articles about using a the ISDataSource control and creating a data adapter...but all these examples assume 3 things, 1) You're connecting to a Db and returning datatables and 2) The Db is located either on the server itself, or in the local environment (I base this on the fact there are two seperate methods that need to be implmented, a select data method and a get count) and 3) The get calls have no input params and cannot be filtered by customerId as in my above code.

 

Ideally what I am looking for is something like the following code snippet. I know this code doesn't exist....but this is the kind of functionality I am looking for:

WebGrid1.PagingEnabled = true;
WebGrid1.PagingMode = PagingMode.Classic;
Users selectedUsers = Users.GetUsers(this._customerId, 1, 25);
WebGrid1.DataSource = selectedUsers;
WebGrid1.MaxPageIndex = selectedUsers.MaxPageIndex;
private void WebGrid1_PageIndexSelected(object sender, PageIndexSelectedArgs args)
{
    Users selectedUsers = Users.GetUsers(this._customerId, args.SelectedPageIndex, 25);
    Webgrid1.DataSource = selectedUsers;
    WebGrid1.MaxPageIndex = selectedUsers.MaxPageIndex;
    WebGrid1.SelectedPageIndex = args.SelectedPageIndex;
}

In theory this should be VERY easy to implement....but I can find any examples of how to do this.

Can anyone help me out?

 

cheers,

 

Steve

 

 

 

 

 

All times are GMT -5. The time now is 11:28 AM.
Previous Next