The EntitySpaces Community

Share and learn about the EntitySpaces Architecture.
Welcome to The EntitySpaces Community Sign in | Join | Help
in
Home Forums Photos

Relationship between esEntityCollection.Sort and DGV display of the sorted column header

Last post 03-15-2008, 11:13 PM by sklett. 4 replies.
Sort Posts: Previous Next
  •  03-15-2008, 3:13 PM 8413

    Relationship between esEntityCollection.Sort and DGV display of the sorted column header

    I'd like to set the sorting on my EntityCollection, then bind to a DGV and have the DGV visually match the sorted column.

    In other words, load a collection, sort on "Last Name DESC", bind to DGV and have the DGV's "Last Name" column show the descending sort icon.

    Before I go off and start experimenting on how to achieve this I thought I should ask here as I'm sure many of you have done this.

    Any suggestions or tips would be great. 

  •  03-15-2008, 5:25 PM 8416 in reply to 8413

    Re: Relationship between esEntityCollection.Sort and DGV display of the sorted column header

    There is no automatic relationship between esEntityCollection.Sort and the DGV sorted column header icon. Why not load the collection, bind it to the DGV, then sort the DGV rather than the collection. That way the icon will be displayed in the column header.

    Code:
    DataGridViewColumn col =
        dataGridView1.Columns[EmployeesMetadata.ColumnNames.LastName];
    dataGridView1.Sort(col, ListSortDirection.Descending);

    David Neal Parsons
    www.entityspaces.net
  •  03-15-2008, 6:08 PM 8417 in reply to 8416

    Re: Relationship between esEntityCollection.Sort and DGV display of the sorted column header

    This is a good idea though I think, we can add it to Trac.

    EntitySpaces | Twitter | BLOG | Please honor our Software License
  •  03-15-2008, 11:12 PM 8418 in reply to 8416

    Re: Relationship between esEntityCollection.Sort and DGV display of the sorted column header

    David,

    A fair question for sure.  The main reason I hadn't taken this approach initially is that my loading of entities and user pref restoration logic (last sorted column) is handled in an application layer that knows nothing (by design) of the DGV.   I was hoping to avoid dragging my DA logic into my presentation.  With that said, a fair argument could be made that sorting preferences are View specific and as such should be set/restored in the presentation layer.

    I'll sleep on it.

    Thanks for the reply, at least I know what to expect now. 

  •  03-15-2008, 11:13 PM 8419 in reply to 8417

    Re: Relationship between esEntityCollection.Sort and DGV display of the sorted column header

    Mike.Griffin:
    This is a good idea though I think, we can add it to Trac.

     

    Something to look forward to :0) 

View as RSS news feed in XML