Pipe( | ) Symbol Filtering

2 posts, 0 answers
  1. Atchyut Bandaru
    Atchyut Bandaru avatar
    7 posts
    Member since:
    Jan 2006

    Posted 02 Dec 2010 Link to this post

    I using teleric control in my proejct. In teleric grid when I am entering the (|) pipe symbal for filtering then I am getting error, Please can you provide me solution for that. 


  2. Veli
    Veli avatar
    2002 posts

    Posted 07 Dec 2010 Link to this post

    Hi Atchyut,

    The pipe symbol is used in RadGrid for delimiting portions of the command argument when sending commands to the server. You need to escape it. To do that, you need to use RadGrid's client-side OnCommand event to encode the filter value, as well as the server-side OnItemCommand to decode it:

    <telerik:RadGrid ID="RadGrid1" runat="server" Width="1000px"
            <ClientEvents OnCommand="gridCommand" />

    function gridCommand(sender, args)
        if (args.get_commandName() == "Filter")
            if (!args.get_tableView()._performFilter)
                var commandArgs = args.get_commandArgument().split("|");
                var fieldName = commandArgs[0];
                var filterFunction = commandArgs[commandArgs.length - 1];
                commandArgs.splice(0, 1);
                commandArgs.splice(commandArgs.length - 1, 1);
                var filterValue = commandArgs.join("|");
                args.get_tableView()._performFilter = true;
                args.get_tableView().filter(fieldName, escape(filterValue), filterFunction);

    private bool fireFilterCommand = false;
    protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
        if (e.CommandName == RadGrid.FilterCommandName)
            if (!fireFilterCommand)
                //if this is the first firing of the Filter command, cancel it,
                // so that we can decode the filter value
                e.Canceled = true;
                Pair filterPair = e.CommandArgument as Pair;
                string dataField = HttpUtility.UrlDecode(filterPair.Second.ToString());
                string filterFunc = filterPair.First.ToString();
                string filterValue = e.Item.OwnerTableView.GetColumn(dataField).CurrentFilterValue;
                //find the filter textbox in the filtering item and set its value
                //to the decoded filter value
                Control filterInput = (e.Item as GridFilteringItem)[dataField].Controls[0];
                if (filterInput is TextBox)
                    ((TextBox)filterInput).Text = HttpUtility.UrlDecode(filterValue);
                //allow firing of Filter command and fire it from the filtering item
                fireFilterCommand = true;
                e.Item.FireCommandEvent(RadGrid.FilterCommandName, new Pair(filterFunc, dataField));
                fireFilterCommand = false;

    Attaching a test page to demonstrate.

    the Telerik team
    Browse the vast support resources we have to jumpstart your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Back to Top