This is a migrated thread and some comments may be shown as answers.

[Solved] Sorting RadGrid by image in GridViewImageColumn

3 Answers 263 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Justin
Top achievements
Rank 1
Justin asked on 12 Jul 2011, 08:22 PM
I have a Telerik Silverlight RadGrid and one of the columns is a GridViewImageColumn. There are only 3 different images ever present in the column and they are relative to the media type that the row represents. I am trying to create a sort such that when you click on the Image Column Header, it reorders the rows into groups using these images. Is there a simple way to achieve this sort/grouping in the code-behind?

Any help is greatly appreciated.

-Justin

3 Answers, 1 is accepted

Sort by
0
Ivan Ivanov
Telerik team
answered on 13 Jul 2011, 12:59 PM
Hello Justin,

I have prepared an example projects that accomplishes this task. Please, refer to it.

All the best,
Ivan Ivanov
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

0
Justin
Top achievements
Rank 1
answered on 13 Jul 2011, 03:13 PM
Thank You Ivan,

    This is exactly what I am looking for as far as sorting is concerned, however one thing that i forgot to mention (my appologies) is that the 3 images are set through an ImageConverter:
<telerik1:GridViewImageColumn Header="Type" DataMemberBinding="{Binding aFile.Name, Converter={StaticResource ImageConverter}}" ImageStretch="None"/>

and the list of possible file names is essentially a FlashFile, 7 Image Types, and 6 Video Types. These being my 3 categories.

    Is there a way to set the SortMemberPath equal to the image returned by that converter, or will i instead need functionality to "look up" which image that would be?

Thanks Again,

--Justin
0
Ivan Ivanov
Telerik team
answered on 13 Jul 2011, 03:27 PM
Hi Justin,

In order to sort a set of elements, you have to be able to compare them, so that the property that is refered as a SortMemberPath has to be of a type that implements IComparable. Since there is no default way of comparing images, setting the image property as a SortMemberPath won't be possible in this case. Please, have a look at this forum thread, it deals with a similar scenario and might prove useful. 

Greetings,
Ivan Ivanov
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

Tags
GridView
Asked by
Justin
Top achievements
Rank 1
Answers by
Ivan Ivanov
Telerik team
Justin
Top achievements
Rank 1
Share this question
or