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

Grid filter

5 Answers 50 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Seban
Top achievements
Rank 1
Seban asked on 07 Feb 2014, 07:18 AM
Sir,

I have a grid , all setting in design,

 AllowFilteringByColumn="True"
EnableLinqExpressions="False" and all columns  properties like    AutoPostBackOnFilter="True" and AllowFiltering="True" , CurrentFilterFunction="Contains" 

, the filter event is fired but no filter string is getting  and grid is not filtered.

 Please help.
by,

Seban

5 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 07 Feb 2014, 08:09 AM
Hi Seban,

Please try the sample code snippet and check if the issue exists. If this doesn't help, please provide you full code snippet because with so little information its hard to identify the issue.

ASPX:
<telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="false" AllowFilteringByColumn="true" OnNeedDataSource="RadGrid1_NeedDataSource" EnableLinqExpressions="false" OnPreRender="RadGrid1_PreRender">
    <MasterTableView>
        <Columns>
         <telerik:GridBoundColumn UniqueName="ID" DataField="ID" HeaderText="ID">
         </telerik:GridBoundColumn>
         <telerik:GridBoundColumn DataField="Name" HeaderText="Name" UniqueName="Name" CurrentFilterFunction="Contains" />
         <telerik:GridTemplateColumn DataField="Number" HeaderText="Number" CurrentFilterFunction="EqualTo">
             <ItemTemplate>
                 <asp:Label ID="Label1" runat="server" Text='<%# DataBinder.Eval( Container, "DataItem.Number") %>'></asp:Label>
             </ItemTemplate>
         </telerik:GridTemplateColumn>
        </Columns>
    </MasterTableView>
</telerik:RadGrid>

C#:
protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
{
    dynamic data = new[] {
new { ID = 1, Name = "Name1", Number=123},
new { ID = 2, Name = "Name2", Number=234},
new { ID = 3, Name = "Name2", Number=234},
new { ID = 4, Name = "Name1", Number=456},
new { ID = 5, Name = "Name5", Number=567},
new { ID = 6, Name = "Name6", Number=567},
new { ID = 7, Name = "Name5", Number=789},
new { ID = 8, Name = "Name1", Number=896},
new { ID = 9, Name = "Name2", Number=741}
};
    RadGrid1.DataSource = data;
}
protected void RadGrid1_PreRender(object sender, EventArgs e)
{
  if (!Page.IsPostBack)
  {
    RadGrid1.MasterTableView.FilterExpression = "([Name] LIKE \'%Name1%\') ";
    GridColumn column = RadGrid1.MasterTableView.GetColumnSafe("Name");
    column.CurrentFilterFunction = GridKnownFunction.Contains;
    column.CurrentFilterValue = "Name1";
    RadGrid1.MasterTableView.Rebind();
  }
}

Thanks,
Shinu

0
Seban
Top achievements
Rank 1
answered on 10 Feb 2014, 08:27 AM
Sir,
I cannot getting the filter experssion.
My grid contains more then ten columns .
please help , very urgent
by,
Seban

I have a grid , all setting in design,



 AllowFilteringByColumn="True"

EnableLinqExpressions="False" and all columns  properties like   
AutoPostBackOnFilter="True" and AllowFiltering="True"
, CurrentFilterFunction="Contains" 



, the filter event is fired but no filter string is getting  and grid is not filtered.

0
Shinu
Top achievements
Rank 2
answered on 10 Feb 2014, 10:14 AM
Hi Seban,

I guess you are trying to filter a column by setting FilterExpression please make sure you have the correct DataField column assigned to it.

RadGrid1.MasterTableView.FilterExpression = "(DataField LIKE \'%SomeValue%\') ";

If you are binding the grid using the NeedDataSource event, you can set the initial filter in the NeedDataSource event handler and omit the call to the Rebind method. The code for setting the filter must still be placed inside an if statement that checks that Page.IsPostBack is False. Note that this is applicable for non auto generated columns.
Without your code its hard to say what's the issue. Please paste your code behind if it doesn't help.

Thanks,
Shinu
0
Seban
Top achievements
Rank 1
answered on 10 Feb 2014, 11:20 AM
Sir,
  Thanks for user reply.

the above code is not working .
  My grid is non auto generated column.
sir my need is no filter is  working in  first population ,
 then the user select the filter test and  filter type. that is my actual need.

please help,
very urgent

by,
  Seban
0
Eyup
Telerik team
answered on 12 Feb 2014, 08:47 AM
Hi Seban,

I'm afraid we are not able to reproduce the problem only from the provided info so far. Can you replicate the described issue with any of our demos?
http://demos.telerik.com/aspnet-ajax/grid/examples/functionality/filtering/basic-filtering/defaultcs.aspx
http://demos.telerik.com/aspnet-ajax/grid/examples/functionality/filtering/filter-templates/defaultcs.aspx

In addition, I have created a sample RadGrid web site to demonstrate that the filtering functionality works as expected. Can you please run the attached application and try to determine the crucial differences between our projects?

Regards,
Eyup
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the UI for ASP.NET AJAX, subscribe to the blog feed now.
Tags
Grid
Asked by
Seban
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Seban
Top achievements
Rank 1
Eyup
Telerik team
Share this question
or