locked
Sorting Datagrid column by certain criteria RRS feed

  • Question

  • I have a datagrid that by default when you click on a column heading it sorts alphabetically. I would like to know how to sort a column by a specific heirarchy. I dont want to sort this in my sql stored procedure, I want to do this on the fly since the default sorting also needs to be a certain way.

    Ex I want it in this order.

    ABC Corp

    XYZ Corp

    DEF Corp

    Friday, September 16, 2011 3:55 PM

Answers

  • In your original question you have mention to sort in strange manner like

    ABC Corp

    XYZ Corp

    DEF Corp

    it is not specifity order you can either sort A-Z or Z-A but in above your code you have first A-Z  and then Z-A mean you have to divide your column into 2 half and then apply first A-Z sorting and then Z-A sorting

    let me know if your problem is not solved, please provide more detail information about your question if I am wrong

    Monday, September 19, 2011 10:00 PM

All replies

  • I have a datagrid that by default when you click on a column heading it sorts alphabetically. I would like to know how to sort a column by a specific heirarchy. I dont want to sort this in my sql stored procedure, I want to do this on the fly since the default sorting also needs to be a certain way.

    Ex I want it in this order.

    ABC Corp

    XYZ Corp

    DEF Corp

    In above example is that one columns field or have two columns ?

    did you see the PagedCollectionView ? if not then here is tutorial about it

    http://www.codeproject.com/Articles/83906/Silverlight-4-Datagrid-Sorting-Grouping-Filtering

    if your problem is not solved then please provide more detail about your question

    Friday, September 16, 2011 10:57 PM
  • It is only 1 column I need to sort by. The rest of the columns can be sorted the way the datagrid normally handles sorting (ie. alphabetically).

    I dont see how in your sample I could sort in a specifc order like I have mentioned in my original questions above.

    Thanks

    Monday, September 19, 2011 11:15 AM
  • In your original question you have mention to sort in strange manner like

    ABC Corp

    XYZ Corp

    DEF Corp

    it is not specifity order you can either sort A-Z or Z-A but in above your code you have first A-Z  and then Z-A mean you have to divide your column into 2 half and then apply first A-Z sorting and then Z-A sorting

    let me know if your problem is not solved, please provide more detail information about your question if I am wrong

    Monday, September 19, 2011 10:00 PM