Tuesday, December 22, 2009

Custom SPGridView

Recently I had to create a custom Grid control that allows user to do grouping, sorting, paging and filtering data displaying in it. I spent few days to figure out if there are third party controls (like Xceed, Infragistics etc) that can meet my requirements. Sadly I found that these controls can't fulfill what I wanted to do.

Well, my requirements were as follows

1. The grid should be used to display a *really large* amount of rows. So fetching every rows from Database will be killing the Application simply.
2. The grid should allow doing sorting at the database level, then the Database indexes can be used for efficiency.
3. The filtering also should be performed by the Database engine.
4. It should allow user to group data in it. As you probably understand that the grouping should also be done by the Database engine.
5. It should offer the similar look-and-feel of native SharePoint 2007 lists.

Now when I tried to find a control (commercial or free) that offers these features, I had no other options but to be disappointed.

Almost all of the controls that I've visited offers all these features but they ask for the entire DataTable in order to bind it. Which is simply not possible for my purpose. Even if I would have used the ObjectDataProvider still I couldn't do the grouping at the Database end.

Interestingly the SPGridView control (shipped by Microsoft) also doesn't allow multiple groupings and in grouped scenarios, the other features like, Filtering, Paging, Sorting doesn't work properly.

Therefore, I have created a custom Grid Control that makes me happy. And eventually I did it. It's not that difficult. I did a complete UI rendition inside the Grid control. Provided an Interface that should be implemented by the client application to provide the data.

It's working for me now. Still I am doing some QC to make sure it's decent enough. After that I'm gonna provide the source of that control. But for now let's have a look onto the video where the Grid control can be seen in Action!



Stay tuned!