Paging and sorting

Posts   
 
    
Posts: 3
Joined: 18-Sep-2006
# Posted on: 19-Sep-2006 14:21:29   

Hello!

I'm wondering what the best approaches is to paging and sorting a gridview when you have methods on a business logic object that returns collections.

When you're using the LLBLGenProDataSource it easy to use LivePersistance and define parameters in the SelectParameters property to filter the data (and this is not really what i want, since i have methods for retrieving the data that i need), but when you get to m:n collections this method won't work (or any collection that is already filtered).

The only method that does work all the time seem to be to bind the gridview directly to the returned collection, but then to allow custom paging i have to overload PageIndexChanging event of the gridview and there retrieve the next records, and to sort i have to overload the Sorting event of the gridview and create a SortingExpression from the sorting string passed to this event (and I have no idea how to do this btw)

I tried to implement the Perform select event of the LLBLGenProDataSource but when i got to sorting, i get records that shouldn't even be in the collection to begin with.

How is paging and sorting typically accomplished? Please give me some examples or at least directions...

Regards shadowbyers

Jessynoo avatar
Jessynoo
Support Team
Posts: 296
Joined: 19-Aug-2004
# Posted on: 19-Sep-2006 15:39:07   

Hi,

I tried to implement the Perform select event of the LLBLGenProDataSource but when i got to sorting, i get records that shouldn't even be in the collection to begin with.

Did you set the sorting mode, and deactivated livepersistence? You should get in control of what you fetch with perform select. Do you mean the resulting collection is not the one you fetched?

Then, you can also access the FilterToUse and SorterToUse properties programmatically. Maybe that's what you're looking for.

Posts: 3
Joined: 18-Sep-2006
# Posted on: 19-Sep-2006 15:58:20   

Hi again, sorry for spamming the forum, this is just for the record wink

It seems that this method for custom paging and sorting works:

Use a LLBLGenProDataSource, set LivePersistance to false, EnablePaging to true. Implement the PerformSelect event handler to:


protected void llblDataSource_PerformSelect(object sender, SD.LLBLGen.Pro.ORMSupportClasses.PerformSelectEventArgs e)
    {
        BusinessLogicHandler handler = new BusinessLogicHandler();   
        SD.LLBLGen.Pro.ORMSupportClasses.LLBLGenProDataSource datasource = (SD.LLBLGen.Pro.ORMSupportClasses.LLBLGenProDataSource)sender;       
        datasource.DataContainerType = SD.LLBLGen.Pro.ORMSupportClasses.DataSourceDataContainerType.EntityCollection;
        datasource.EntityCollection = handler.GetCollectionUsingGetMultiOrEvenGetMultiManyToMany(e.PageNumber, e.PageSize, e.Sorter)
        datasource.DataBind(); 
    }

Implement PerformGetDbCount event handler


protected void llblDataSource_PerformGetDbCount(object sender, SD.LLBLGen.Pro.ORMSupportClasses.PerformGetDbCountEventArgs e)
    {
        BusinessLogicHandler handler = new BusinessLogicHandler(); 
        
        e.DbCount = handler.GetNumberOfObjectsInTheCollectionWeAreListing()
    }

Add a GridView, set its datasource to the LLBLGenProDataSource using the smart tag, set AllowSorting to true and AllowPaging to true.

In the GetCollection methods of the business logic object when using SomeCollectionViaSomeEntityToSomeOtherEntity property of an entity (this is the mapping of a m:n relation as i have understood it) i had to use GetMultiManyToMany on that property and send in the arguments for paging and sorting to that method

Hope any of this made sense, i've only looked at this LLBLGenPro stuff for a week so i'm still very confused simple_smile

Regards