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

[Solved] GridCheckBoxColumn with image display values

1 Answer 355 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Eric
Top achievements
Rank 1
Eric asked on 07 Dec 2009, 09:10 PM
I am fairly new to using RadGrid and my terminology and approach may be off, but...

I would like to add a boolean-type column to a RadGrid that is filterable using a checkbox, but renders in each row with one of two images (true=green check-mark, false=red X)

I have tried adding a GridCheckBoxColumn and it provids the checkbox in the filter as desired, but it renders true and false in the Grid with a checkbox which is checked or not checked.

Similarly, I have tried adding a GridImageColumn and it renders true and false values with the check-mark and X images, but the filter cell provides a text field to filter on, not a checkbox.

Is there an obvious way to do what I am trying to do? Would it be to start with a checkbox column and customize how the cells are rendered, or to start with an image column and customize how the filter cell behaves, or maybe some other approach?

Thanks,
-Eric

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 08 Dec 2009, 05:52 AM
Hello Eric,

You can use the FilterTemplate for columns to use custom filter controls for different columns. In your case, you can either use a GridImageColumn with a checkbox in its FilterTemplate or a GridTemplateColumn with a checkbox in its FilterTemplate.
aspx:
<telerik:GridTemplateColumn UniqueName="TemplateColumn" HeaderText="Status"
    <FilterTemplate> 
     <asp:CheckBox ID="CheckBox1" AutoPostBack="true" runat="server" /> 
    </FilterTemplate> 
    <ItemTemplate>                          
     <asp:Image ID="Image1" runat="server" ImageUrl='<%# Convert.ToBoolean(DataBinder.Eval(Container.DataItem, "Status"))? "Image/Check.gif" : "Image/Cross.gif" %>' /> 
    </ItemTemplate> 
</telerik:GridTemplateColumn> 
 
<telerik:GridImageColumn UniqueName="ImageColumn" HeaderText="Condition"
    <FilterTemplate> 
     <asp:CheckBox ID="CheckBox2" AutoPostBack="true" runat="server" /> 
    </FilterTemplate> 
</telerik:GridImageColumn> 

Also refer to the following document to find out more on FilterTemplates:
Filter template

Thanks
Princy.
Tags
Grid
Asked by
Eric
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or