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

Grid filter

2 Answers 43 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Seban
Top achievements
Rank 1
Seban asked on 30 Jan 2014, 05:14 AM
Dear Konstantin Dikov,



Thanks for your replay.



My grid contains three columns, named as ID, NAME and SELECTED. The
"SELECTED" column is template column contains one check box with
Autopostback=false. And, I applied the filter to the NAME column, its a
bound bound column.



When I applied the filter to NAME column, I want to show the all record
based on the Name column filter and already I checked items (the
SELECTED Column) in that grid.



ie., The filter condition string is : Name LIKE '%telerik%' AND SELECTED = true



please reply .

very urgent.



Thanks,

Jessy

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 30 Jan 2014, 07:27 AM
Hi Jessy,

In order to filter a TemplateColumn, please set its DataField property for that column. Please check the below code snippet:

ASPX:
<telerik:GridBoundColumn DataField="Name" HeaderText="Name" UniqueName="Name" />
<telerik:GridTemplateColumn DataField="SELECTED">
    <ItemTemplate>
        <asp:CheckBox ID="CheckBox1" runat="server" Checked='<%#DataBinder.Eval(Container.DataItem,"SELECTED") is DBNull ?false:Eval("SELECTED")) %>' />
    </ItemTemplate>
</telerik:GridTemplateColumn>

C#:
protected void RadGrid1_PreRender(object sender, EventArgs e)
 {     
   if (!Page.IsPostBack)
   {
     foreach (GridDataItem item in RadGrid1.Items)
     {
       string filter = "[Name]= 'Name' AND [SELECTED] = True ";
       RadGrid1.MasterTableView.FilterExpression = filter;             
       RadGrid1.MasterTableView.Rebind();
     }
   }
 }

Thanks,
Princy
0
Princy
Top achievements
Rank 2
answered on 30 Jan 2014, 07:27 AM
Hi Jessy,

In order to filter a TemplateColumn, please set its DataField property for that column. Please check the below code snippet:

ASPX:
<telerik:GridBoundColumn DataField="Name" HeaderText="Name" UniqueName="Name" />
<telerik:GridTemplateColumn DataField="SELECTED">
    <ItemTemplate>
        <asp:CheckBox ID="CheckBox1" runat="server" Checked='<%#DataBinder.Eval(Container.DataItem,"SELECTED") is DBNull ?false:Eval("SELECTED")) %>' />
    </ItemTemplate>
</telerik:GridTemplateColumn>

C#:
protected void RadGrid1_PreRender(object sender, EventArgs e)
 {      
   if (!Page.IsPostBack)
   {
     foreach (GridDataItem item in RadGrid1.Items)
     {
       string filter = "[Name]= 'Name' AND [SELECTED] = True ";
       RadGrid1.MasterTableView.FilterExpression = filter;              
       RadGrid1.MasterTableView.Rebind();
     }
   }
 }

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