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

[Solved] FilterExpression does not work after upgrade to last version of Telerik

3 Answers 341 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ivan Aquino
Top achievements
Rank 1
Ivan Aquino asked on 13 Aug 2009, 07:17 PM
Hi all. After upgrading to the 2009 Q2 version of ASP.NET AJAX controls, the filterexpression property of radgrid does not work anymore. I mean that the initial filter(When page load) is not filtering anything. My radgrid is binded using a list of custom objects, and the filterexpression code block that I use is:

if (Assembly.GetAssembly(typeof(ScriptManager)).FullName.IndexOf("3.5") != -1)
            {
                rgMenu.MasterTableView.FilterExpression = @"it[""ParentMenuID""] == Guid.Empty";
            }
            else
            {
                rgMenu.MasterTableView.FilterExpression = "ParentMenuID== Guid.Empty";
            }


In the avobe mentioned code, ParentMenuID is a property of my custom object, and I want to filter the list of this objects, showing only the ones who have ParentMenuID == Guid.Empty.

I will really appreciate your help and response.

Thanks  a lot

Ivan Aquino

3 Answers, 1 is accepted

Sort by
0
Tsvetoslav
Telerik team
answered on 14 Aug 2009, 06:32 AM
Hello Ivan,

Are you getting any error messages or the rows are just not being filtered? Could you try setting EnableLinqExpressions for the grid to false and if the problem persists pasted you aspx and code behind (please, use the Code Formatter tool of the ticket html editor).

Thank you.

Best Regards,
Tsvetoslav
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Ivan Aquino
Top achievements
Rank 1
answered on 17 Aug 2009, 06:41 PM
It does not show any error, it just show all the items of the list of custom objects(without filtering). I reproduce the error in the following code.

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %> 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 
<html xmlns="http://www.w3.org/1999/xhtml"
<head runat="server"
    <title></title
</head> 
<body> 
    <form id="form1" runat="server"
    <asp:ScriptManager ID="smMgr" runat="server"
</asp:ScriptManager> 
 
    <div> 
         <telerik:RadGrid ID="rgMenu" runat="server" OnNeedDataSource="OnNeedDataSource" 
         AutoGenerateColumns="false" EnableLinqExpressions="false"
            <MasterTableView runat="server" AllowSorting="true" AutoGenerateColumns="false" DataKeyNames="name,lastname"
                <Columns> 
                    <telerik:GridBoundColumn DataField="name" > 
                    </telerik:GridBoundColumn> 
                     <telerik:GridBoundColumn DataField="lastname" > 
                    </telerik:GridBoundColumn> 
                </Columns> 
            </MasterTableView> 
         </telerik:RadGrid> 
    </div> 
 
    </form> 
</body> 
</html> 



using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Web; 
using System.Web.UI; 
using System.Web.UI.WebControls; 
using Telerik.Web.UI; 
 
public partial class _Default : System.Web.UI.Page  
    protected void Page_Load(object sender, EventArgs e) 
    { 
        rgMenu.MasterTableView.FilterExpression = @"lastname == Guid.Empty "
    } 
    protected void OnNeedDataSource(object source, GridNeedDataSourceEventArgs e) 
    { 
        List<Customer> list = new List<Customer>(); 
        list.Add(new Customer() { name = "Ivan", lastname = Guid.NewGuid() }); 
        list.Add(new Customer() { name = "Gustavo", lastname = Guid.NewGuid() }); 
        list.Add(new Customer() { name = "Ernesto", lastname = Guid.NewGuid() }); 
        list.Add(new Customer() { name = "Richard", lastname = Guid.Empty }); 
        list.Add(new Customer() { name = "Aldo", lastname = Guid.Empty }); 
        list.Add(new Customer() { name = "Rony", lastname = Guid.Empty }); 
        rgMenu.DataSource = list; 
    } 
    class Customer 
    { 
        public string name { getset; } 
        public Guid lastname { getset; } 
    } 
 
0
Tsvetoslav
Telerik team
answered on 19 Aug 2009, 11:29 AM
Hello Ivan,

You need to change your filter expression to:

rgMenu.MasterTableView.FilterExpression = "[lastname] = '" +  Guid.Empty + "'"

I hope this helps.

All the best,
Tsvetoslav
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
Ivan Aquino
Top achievements
Rank 1
Answers by
Tsvetoslav
Telerik team
Ivan Aquino
Top achievements
Rank 1
Share this question
or