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

AllowFilteringByColumn

7 Answers 405 Views
Grid
This is a migrated thread and some comments may be shown as answers.
JSON
Top achievements
Rank 1
JSON asked on 08 Feb 2013, 08:21 PM
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

7 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 11 Feb 2013, 07:05 AM
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.
0
JSON
Top achievements
Rank 1
answered on 11 Feb 2013, 02:54 PM
Shinu,

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

SteveO...
0
rajat
Top achievements
Rank 1
answered on 23 Jul 2018, 02:18 PM

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

0
Eyup
Telerik team
answered on 26 Jul 2018, 12:33 PM
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.
0
rajat
Top achievements
Rank 1
answered on 28 Jul 2018, 03:49 PM

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

0
rajat
Top achievements
Rank 1
answered on 30 Jul 2018, 01:49 PM
Please respond with the same query.
0
Eyup
Telerik team
answered on 02 Aug 2018, 05:40 AM
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.
Tags
Grid
Asked by
JSON
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
JSON
Top achievements
Rank 1
rajat
Top achievements
Rank 1
Eyup
Telerik team
Share this question
or