none
Sortmember path issue in datagrid??

    Question

  • Hi,

    I am using silverlight 3. i am using sortmemberpath for sorting records in datagrid. its work finely.

    But one of my column is datatime column... its not sorting properly ascending as well as descending..some date time values coming in middle rows without ascending as well as descending

    If any one knows pls reply as soon as possible

    Thanks in advance.

    Monday, April 30, 2012 8:44 AM

Answers

  • Hi jafferpg, 

    Please make sure the data field is defined as DateTime type. 

    On my side the DateTime type field can be sorted correctly. 

    Best Regards,

    Wednesday, May 23, 2012 5:31 AM
  • Hi jafferpg,

    Based on your description, i think the main point the remember the sorted column and sort direction and when refreshing data source, you will be able to set previous sorted column and sort direction in advance.

    I suggest you bind PagedCollectionView to DataGrid's ItemsSource and attach CollectionChanged event handler to detect when sort is changed.

    pcv.CollectionChanged += new NotifyCollectionChangedEventHandler(pcv_CollectionChanged);

     

    SortDescriptionCollection sortCollection;

             void pcv_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)

            {

                 sortCollection = pcv.SortDescriptions;//Save SortDescriptions to a public variable.

             }

     

    When the collection is udpated, loop through sortCollection and added it back to PagedCollectionView.

                foreach (SortDescription sort in sortCollection)

                {

                     pcv.SortDescriptions.Add(sort);

                 }

     

    Best Regards,

    Monday, June 11, 2012 5:56 AM

All replies

  • Hi jafferpg,

    I cannot reproduce this issue on my side.

    If manually click on the dateTime column header, will the data sorted as expected?

    If possible please post some examples data and related code here to help me reproduce this issue.

     

    Best Regards,

    Tuesday, May 01, 2012 3:13 AM
  • HI Shi Ding

    Thanks for your reply..

    Please see this

    Sortmember path sort by first letter only... any other solution is there?

    Please reply if knows.

    Thanks in advance.

    Wednesday, May 02, 2012 5:34 AM
  • sorry here attached the sample.

    Wednesday, May 02, 2012 5:35 AM
  • Hi jafferpg,

    Sorry I missed your last replies. Could you post the related code here, then i will be able to test it and try to find the cause of the issue?

     

    Best Regards,

    Wednesday, May 09, 2012 1:51 AM
  • Hi shi ding,

    Please click reply in my last reply. then it will be visible sample one which one i posted..

    I copied and posted using ms office info path its not visible... so please do this....

    Friday, May 11, 2012 8:39 AM
  • Hi jafferpg,

    ok I saw the screen shot, but could you post related code here. Then i will be able to test it on my side.

     

    Best Regards,

    Sunday, May 13, 2012 9:40 PM
  • Hi shi ding..

    I am not use any code for sorting

    Jus use sortmemeber path in datagrid for example

    <data:DataGridTemplateColumn Width="150" Header="Licence. exp date " SortMemberPath="date">
                                <data:DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <TextBlock Text="{Binding date}" FontSize="12" VerticalAlignment="Center" Height="auto"/>
                                    </DataTemplate>
                                </data:DataGridTemplateColumn.CellTemplate>
                            </data:DataGridTemplateColumn>

    This only.. thanks for your reply...

    Thursday, May 17, 2012 10:33 AM
  • Hi jafferpg, 

    Please make sure the data field is defined as DateTime type. 

    On my side the DateTime type field can be sorted correctly. 

    Best Regards,

    Wednesday, May 23, 2012 5:31 AM
  • Hi ShiDing,

    Yes in Datafield i used as  a string.

    Thanks for your reply...  Thanks a lot.

    Wednesday, May 23, 2012 6:57 AM
  • Hi shiDing,

    Thanks you again.

    Again one problem in sortmember path. i am using auto refresh data grid in main page. . if user sorting one column means within few seconds it get refresh and show default order by ID.

    How can i over come this?

    Please explain...

    Thursday, May 24, 2012 1:34 AM
  • Hi jafferpg,

    Could you eleborate on how the datagrid is auto refreshed or post related code here to better explain this.

     

    Best Regards,

    Tuesday, May 29, 2012 10:21 PM
  • Hi shi Ding,

    I am using dispatchertimer for datagrid.. it refresh 100 milli seconds once...

    If i sorting particular column in datagrid its get refresh within 100 millliseconds... so user cant able to view the sorting column

    Please tel any solution is there.... i cant able to remove the dispatchtimer... coz its very needful for some other purpose.

    This sorting only drawback. I am using silverlight 3.

    Thanks in advance

    Monday, June 04, 2012 8:51 AM
  • Hi shi Ding.

    Its urgent issue.... please reply if you know as soon as possible.

    Thanks

    Friday, June 08, 2012 5:08 AM
  • Hi jafferpg,

    Based on your description, i think the main point the remember the sorted column and sort direction and when refreshing data source, you will be able to set previous sorted column and sort direction in advance.

    I suggest you bind PagedCollectionView to DataGrid's ItemsSource and attach CollectionChanged event handler to detect when sort is changed.

    pcv.CollectionChanged += new NotifyCollectionChangedEventHandler(pcv_CollectionChanged);

     

    SortDescriptionCollection sortCollection;

             void pcv_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)

            {

                 sortCollection = pcv.SortDescriptions;//Save SortDescriptions to a public variable.

             }

     

    When the collection is udpated, loop through sortCollection and added it back to PagedCollectionView.

                foreach (SortDescription sort in sortCollection)

                {

                     pcv.SortDescriptions.Add(sort);

                 }

     

    Best Regards,

    Monday, June 11, 2012 5:56 AM
  • Hi shi Ding,

    Yeah its working . Perfect.

    Thanks a lot. you saved my a lot of time.

    Once again thanks.

    Tuesday, June 12, 2012 6:45 AM