Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
360
Sort column With Image
posted

I took a look at the samples and pretty much copied the xaml to place an image in one of the cells.  The images i am using actually mean something to my users, and i need some way to sort those images.  For example if i have an image that means Error, another image that means Caution, and i want all of the "Error" to show at the top and then the Cautions below that ect.  Can anyone advise of a way where i can do that.  I have a column in my object but that is hidden that is basically and Enumeration but it is not even defined in the field layout.  It would be nice if i could also keep the default sorting of the other columns, meaing that i don't change the behaviour completely.

Parents
  • 9836
    Verified Answer
    posted

    Hello,

    One possible implementation is to handle the Sorted event of the grid and then sort the image column based on your enumeration column values. You would need to add the enumeration column to the fieldlayout so you can point to this field when you create the FieldDescription :

    private void xamDataGrid1_Sorted(object sender, Infragistics.Windows.DataPresenter.Events.SortedEventArgs e)
    {
           Field current = e.Field;
           if (current.Name == "ImageColumn")
           {
                   FieldSortDescription enumSort = new FieldSortDescription();
                   enumSort.Direction = System.ComponentModel.ListSortDirection.Ascending;
                   enumSort.FieldName = "EnumerationColumn";

                  this.xamDataGrid1.FieldLayouts[0].SortedFields.Clear();
                  this.xamDataGrid1.FieldLayouts[0].SortedFields.Add(enumSort);
           }
    }

    I hope this helps.

    Vlad

Reply Children
No Data