how to set SupportsSorting to true on relations

Posts   
 
    
erwin avatar
erwin
User
Posts: 21
Joined: 18-Feb-2005
# Posted on: 01-Nov-2005 17:41:27   

I'm binding an EntityCollection that has relations to other EntityCollections to the Windows Forms Datagrid. As far as I understand, by setting SupportsSorting=true I get client sorting behaviour. This fine works for the indicated base collection.

void BindCollection(EntityCollectionBase ecb) { ecb.SupportsSorting=true; dataGrid1.DataSource = ecb; dataGrid1.ReadOnly = true; }

However, when the user navigates to a related collection in the grid, the releated collections returned by GetMulti.... have SupportsSorting set to false (the default Value). Is there an elegant way to set this to true so that the user can sort the grid after navigating to a related collection?

Erwin

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 02-Nov-2005 19:15:39   

The most 'elegant' way I think is to create an include template which generates code to set the property on the collection private member variables for 1:n and m:n relations. If you need help writing that template, let me know.

Frans Bouma | Lead developer LLBLGen Pro
erwin avatar
erwin
User
Posts: 21
Joined: 18-Feb-2005
# Posted on: 06-Nov-2005 23:25:35   

Otis wrote:

The most 'elegant' way I think is to create an include template which generates code to set the property on the collection private member variables for 1:n and m:n relations. If you need help writing that template, let me know.

Ok, I don't feel up to the level with LLBLGen at the moment to try that... Not urgent, just "nice to have", will have a look at the docs first.

Thanks!

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 08-Nov-2005 11:23:05   

Those two lines in a template file, bind it to the template id: Custom_EntityInitializationTemplate in a custom template set (see Adding your own code to the generated classes in the documentation for details) and use that template set for code generation, you'll then have the code inside the entity init routines which means it will always run.


    <[Foreach RelatedEntity OneToMany CrLf]>        _<[CaseCamel MappedFieldNameRelation]>.SupportsSorting = true;[NextForeach]>
    <[Foreach RelatedEntity ManyToMany CrLf]>       _<[CaseCamel MappedFieldNameRelation]>.SupportsSorting = true;[NextForeach]>

Frans Bouma | Lead developer LLBLGen Pro