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

Input form value to filter grid page

1 Answer 117 Views
Grid
This is a migrated thread and some comments may be shown as answers.
steven
Top achievements
Rank 1
steven asked on 18 Dec 2010, 03:58 PM

I have created a Asp.Net 4.0 page with a RadGrid. One of the columns (ConsignorId) indicates that this record belongs to a specific Consignor.  A consignor can have multiple records. I would like to have a input(textbox) where I could enter a ConsignorId and then render the page with the RadGrid with only the records selected based on the consigorid entered.

Could you refer me to an example for this? I am new to telerek.

Thank You

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 22 Dec 2010, 12:22 PM
Hello Steven,

You can attach 'onkeydown' client event to the TextBox(which is outside grid) like below.
ASPX:
<asp:TextBox ID="TextBox1" runat="server" onkeydown="doFilter(this,event)"></asp:TextBox>

Then in that event handler directly set the ColumnUniqueName for which you are using that filtering TextBox.

Java Script:
<script type="text/javascript">
    function doFilter(sender, eventArgs) {
        if (eventArgs.keyCode == 13) {
            eventArgs.cancelBubble = true;
            eventArgs.returnValue = false;
            if (eventArgs.stopPropagation) {
                eventArgs.stopPropagation();
                eventArgs.preventDefault();
            }
            var masterTableView = $find("<%= RadGrid1.ClientID %>").get_masterTableView();
            var uniqueName = "EmployeeID"; // set Column UniqueName for the filtering TextBox
            masterTableView.filter(uniqueName, sender.value, Telerik.Web.UI.GridFilterFunction.Equals);
        }
    }
</script>

Note: You need to set AllowFilteringByColumn property of RadGrid as true to filter the column.

Thanks,
Princy.
Tags
Grid
Asked by
steven
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or