AllowFilteringByColumn

8 posts, 0 answers
  1. JSON
    JSON avatar
    78 posts
    Member since:
    Mar 2010

    Posted 08 Feb 2013 Link to this post

    Hello,

    I have a radgrid definition that has AllowFilteringByColumn enabled. One of the grid column's is populated from a RadComboBox using a lookup table (via a foreign key). The filter in this case, only works on the foreign key value. (see screen shot)

    Is it possible to configure this filer to accept the text value.

                    <telerik:GridDropDownColumn DataField="UnitId" 
                                                UniqueName="Unit" 
                                                HeaderText="Unit" 
                                                AllowSorting="true" 
                                                ItemStyle-Width="100px" 
                                                DataSourceID="EntityDataSource1" 
                                                DropDownControlType="RadComboBox" 
                                                ListTextField="Unit"
                                                ListValueField="UnitId" 
                                                EmptyListItemText=""
                                                EmptyListItemValue="">
                    </telerik:GridDropDownColumn>

    Thanks,

    SteveO
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 11 Feb 2013 Link to this post

    Hi,

    I guess you want to filter the GridDropDownColumn by the ListValueField.  The built-in GridDropDownColumn is filtered by its ListValueField when the default filtering feature of the control is used. RadGrid does not include any support for filtering by ListTextField instead.

    This limitation is because the filtering mechanism relies on the DataField of the filtered column and for GridDropDownColumn this property specifies the mapping field in the drop-down source. Use a hidden GridBoundColumn (with Display = false). Add an ItemCommand event handler that catches filter commands from the dropdown column and substitutes a filter command from the GridBoundColumn instead Please check the following code snippet I tried.

    ASPX:
    <telerik:RadGrid ID="RadGrid1" DataSourceID="SqlDataSource1"
        AutoGenerateColumns="false" AllowFilteringByColumn="true" runat="server"
        onitemcommand="RadGrid1_ItemCommand" onitemdatabound="RadGrid1_ItemDataBound">
        <MasterTableView>
            <Columns>
                <telerik:GridDropDownColumn UniqueName="CategoryddColumn" ListTextField="CategoryName"
                    HeaderText="Category name" ListValueField="CategoryID" DataField="CategoryID"
                    DataSourceID="SqlDataSource1">
                </telerik:GridDropDownColumn>
                <telerik:GridBoundColumn DataField="CategoryName" HeaderText="CategoryName" SortExpression="CategoryName"
                    UniqueName="CategoryName" Display="false">
                </telerik:GridBoundColumn>
            </Columns>
        </MasterTableView>
    </telerik:RadGrid>

    C#:
    protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e)
    {
        if (e.CommandName == RadGrid.FilterCommandName)
        {
            Pair command = (Pair)e.CommandArgument;
            if (command.Second.ToString() == "CategoryddColumn")
            {
                e.Canceled = true;
                GridFilteringItem filter = (GridFilteringItem)e.Item;
                ((filter["CategoryName"].Controls[0]) as TextBox).Text = ((filter["CategoryddColumn"].Controls[0]) as TextBox).Text;
                command.Second = "CategoryName";
                filter.FireCommandEvent("Filter", new Pair(command.First, "CategoryName"));
            }
        }
    }
    protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
        if (e.Item is GridFilteringItem)
        
            GridFilteringItem item = e.Item as GridFilteringItem;
            ((item["CategoryddColumn"].Controls[0]) as TextBox).Text = ((item["CategoryName"].Controls[0]) as TextBox).Text;
        }
    }

    Please check this help documentation for details.

    Thanks,
    Shinu.
  3. JSON
    JSON avatar
    78 posts
    Member since:
    Mar 2010

    Posted 11 Feb 2013 Link to this post

    Shinu,

    Great! Worked like a charm. Thanks for your help.

    SteveO...
  4. rajat
    rajat avatar
    5 posts
    Member since:
    Apr 2014

    Posted 23 Jul 2018 Link to this post

    Hi Team,

    I am using AllowFilteringbyColumn in telerik:Gridtableview in my application and we need to implement the WCAG Compliance.

    Please let me know how can we implement aria-label for allowFilteringByColumn textboxes.

    I tried EnableAriaSupport but it did not worked.

    Regards

  5. Eyup
    Admin
    Eyup avatar
    3990 posts

    Posted 26 Jul 2018 Link to this post

    Hello Rajat,

    You can use the ItemDataBound event handler to access the filter TextBox and add the desired attributes to it:
    https://www.telerik.com/forums/force-a-filter-to-be-applied-on-enter-key#iAhKwV2sJk6XfuLfw7Dg-w

    You can find here information about the differences of ItemCreated and ItemDataBound:
    http://docs.telerik.com/devtools/aspnet-ajax/controls/grid/control-lifecycle/differences-between-itemcreated-and-itemdatabound-

    I hope this will prove helpful.

    Regards,
    Eyup
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  6. rajat
    rajat avatar
    5 posts
    Member since:
    Apr 2014

    Posted 28 Jul 2018 in reply to Eyup Link to this post

    Thank you Eyup for quick reply.

    Also I want back to focus on same tab [from where it is initiated] after clicking first, last prev and Next also on Paging. So what approach we can follow for the same. Actually we are in process of WCAG compliance so we need focus back if we hit on any button or postback.

    Please share code snippet, that will be highly appreciated.

    Please suggest.

    Regards

    Rajat

  7. rajat
    rajat avatar
    5 posts
    Member since:
    Apr 2014

    Posted 30 Jul 2018 Link to this post

    Please respond with the same query.
  8. Eyup
    Admin
    Eyup avatar
    3990 posts

    Posted 02 Aug 2018 Link to this post

    Hi Rajat,

    You need to manually determine which element made the action and apply the focus back to it after the PostBack or AJAX request. I am sending 2 web site samples which can give you some ideas.

    Regards,
    Eyup
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top