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

ImageColumn Filter / DataColumn

8 Answers 73 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 1
Mark asked on 21 Apr 2011, 06:42 PM
I am currently pushing a bool through an IValueConverter to the ImageColumn and it is working without issue.  I'd like to still be able to filter the column basis the true / false values.  I'm beliving that the manner to do this is not currently availble in the imagecolumn type and I have to build a DataColumn with the template.

If I can filter an ImageColumn basis values, please advise. 

If I'm correct and I need to go a different column type, I'm having difficulty.
I'm trying:

<telerik:RadGridView.Columns>
                        <telerik:GridViewDataColumn UniqueName="txt_CI_Origin" Header="Origin" DataMemberBinding="{Binding Path=origin}" />
                        <telerik:GridViewDataColumn UniqueName="txt_CI_Qty" Header="Qty" DataMemberBinding="{Binding Path=quantity}" IsFilterable="False" IsGroupable="False" />
                        <telerik:GridViewDataColumn UniqueName="txt_CI_Pkg" Header="Packaging" DataMemberBinding="{Binding Path=packDesc}" IsFilterable="False" IsGroupable="False" />
                        <telerik:GridViewDataColumn UniqueName="txt_CI_VG" Header="Varietal" DataMemberBinding="{Binding Path=varietal}" />
                        <telerik:GridViewDataColumn UniqueName="txt_CI_Chop" Header="Chop - Mark" DataMemberBinding="{Binding Path=chopMark}" />
                        <telerik:GridViewImageColumn UniqueName="chk_CI_OrgC" Header="Organic" DataMemberBinding="{Binding Path=isOrganic, Converter={StaticResource BoolToImageConverter}}" />
                        <telerik:GridViewImageColumn UniqueName="chk_CI_ExC" Header="Ex. Cert." DataMemberBinding="{Binding Path=isCert, Converter={StaticResource BoolToImageConverter}}" />
                        <telerik:GridViewImageColumn UniqueName="chk_CI_Decaf" Header="Decaf." DataMemberBinding="{Binding Path=isDecaf, Converter={StaticResource BoolToImageConverter}}" />
                        <telerik:GridViewDataColumn UniqueName="isDecaf" DataMemberBinding="{Binding Path=isDecaf}">
                            <telerik:GridViewColumn.CellStyle>
                                <Style TargetType="telerik:GridViewCell">
                                    <Setter Property="Template">
                                        <Setter.Value>
                                            <ControlTemplate TargetType="telerik:GridViewCell">
                                                <Image Source="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Content, Converter={StaticResource BoolToImageConverter}}" />
                                            </ControlTemplate>
                                        </Setter.Value>
                                    </Setter>
                                </Style>
                            </telerik:GridViewColumn.CellStyle>
                        </telerik:GridViewDataColumn>
                    </telerik:RadGridView.Columns>

however no image is shown on the DataColumn.

8 Answers, 1 is accepted

Sort by
0
Mark
Top achievements
Rank 1
answered on 21 Apr 2011, 06:59 PM
I sorted the DataColumn piece .. for anyone interested the corrected code is below. 
If I can please just have a confirm on as to whether the imagecolumn supports filtering.

Many thanks,
Mark

<telerik:GridViewDataColumn UniqueName="isDecaf" DataMemberBinding="{Binding Path=isDecaf}">
                            <telerik:GridViewColumn.CellStyle>
                                <Style TargetType="telerik:GridViewCell">
                                    <Setter Property="Template">
                                        <Setter.Value>
                                            <ControlTemplate TargetType="telerik:GridViewCell">
                                                <Image Source="{Binding isDecaf, Converter={StaticResource BoolToImageConverter}}" />
                                            </ControlTemplate>
                                        </Setter.Value>
                                    </Setter>
                                </Style>
                            </telerik:GridViewColumn.CellStyle>
                        </telerik:GridViewDataColumn>
0
Vanya Pavlova
Telerik team
answered on 21 Apr 2011, 07:08 PM
Hi Mark,

 
The better approach here is to define CellTemplate rather than to predefine the GridViewCell's ControlTemplate for this column, as shown below:

<telerik:GridViewDataColumn UniqueName="isDecaf" DataMemberBinding="{Binding Path=isDecaf}">
                            <telerik:GridViewDataColumn.CellTemplate>
                              <DataTemplate>
                                                <Image Source="{Binding isDecaf, Converter={StaticResource BoolToImageConverter}}" />
                                       
                                     </DataTemplate>
                            </telerik:GridViewDataColumn.CellTemplate>
                        </telerik:GridViewDataColumn>


Now the appropriate image will be returned based on the underlying boolean property value of your custom business object.


Greetings,
Vanya Pavlova
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Alexander
Top achievements
Rank 1
answered on 04 May 2011, 01:57 PM
Hello everybody,
I am using the approach you have described above. It works perfectly, but I am not able to filter the column data, even if I set IsFilterable property to TRUE. Is there a way to have a filter on such a column ?
0
Vanya Pavlova
Telerik team
answered on 04 May 2011, 02:12 PM
Hi Alexander,

 
Since you have specified the DataMemberBinding everything will work as expected.
Please check the attached project and let me know how it differs from yours.


All the best,
Vanya Pavlova
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Alexander
Top achievements
Rank 1
answered on 05 May 2011, 07:48 AM
The only difference is that the property that I bind to in DataMemberBinding is of type byte[], not bool. Below is the xaml code I use:
<telerik:GridViewDataColumn Header="Flag"   DataMemberBinding="{Binding CountryFlag,  Converter={StaticResource ByteToImage}}">
    <telerik:GridViewDataColumn.CellTemplate>
        <DataTemplate>
         <Image Source="{Binding CountryFlag, Converter={StaticResource ByteToImage},  Mode=TwoWay,   UpdateSourceTrigger=Default}" 
Width="32"  Height="32" />
      </DataTemplate>
     </telerik:GridViewDataColumn.CellTemplate>
</telerik:GridViewDataColumn>


0
Vanya Pavlova
Telerik team
answered on 05 May 2011, 10:20 AM
Hi Alexander,

 

May you please share with us how the grid is bound in your case?
In my opinion I believe that the better option is to submit a new support ticket and attach small repro application which we can use for testing. 

Kind regards,
Vanya Pavlova
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Alexander
Top achievements
Rank 1
answered on 12 May 2011, 03:47 PM
Hello,
You can use the "First Look" application from RadGridView demo on your site. There you also have a column with image and it also cannot be filtered.
0
Vlad
Telerik team
answered on 12 May 2011, 03:55 PM
Hello,

 Since you have CellTemplate you can provide different (filterable) DataMemberBinding instead the current one. 

Regards,
Vlad
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
GridView
Asked by
Mark
Top achievements
Rank 1
Answers by
Mark
Top achievements
Rank 1
Vanya Pavlova
Telerik team
Alexander
Top achievements
Rank 1
Vlad
Telerik team
Share this question
or