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

ClienteSide_OnKeyPress

4 Answers 22 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Paulo
Top achievements
Rank 1
Paulo asked on 30 Jan 2014, 08:39 PM
Hi I have a RadGrid with several columns one of the columns has a RadTextBox which user will type something hit enter and call a javascript filter function as you can see below. Any thought about how could I call my javascript function.

4 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 31 Jan 2014, 04:22 AM
Hi Paulo,

Please try the following code snippet to have filter on clientside:

ASPX:
<telerik:GridTemplateColumn UniqueName="ShipName" DataField="ShipName" HeaderText="ShipName">
    <ItemTemplate>
       <asp:Label ID="lblname" runat="server" Text='<%#Eval("ShipName")%>' />    
    </ItemTemplate>
    <FilterTemplate>
     <telerik:RadTextBox ID="txtFilter" Text='<%#Container.OwnerTableView.GetColumn"ShipName").CurrentFilterValue %>' runat="server"  onkeydown="key(event,this);">         
        </telerik:RadTextBox>
        <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">       
                function key(event, sender) {
                    if (event.keyCode == 13) {                    
                        var filterValue = "";
                        var filterFunction = "NoFilter";
                        var name = sender.value;
                        if (name != "") {
                            filterValue = name;
                            var filterFunction = "Contains";
                        }
                        var tableView = $find("<%# ((GridItem)Container).OwnerTableView.ClientID %>");
                        tableView.filter("ShipName", filterValue, filterFunction);
                    }
                }
            </script>
        </telerik:RadScriptBlock>
    </FilterTemplate>
</telerik:GridTemplateColumn>

Thanks,
Princy
0
Paulo
Top achievements
Rank 1
answered on 31 Jan 2014, 05:51 PM
Thank you Princy for your response. I will try using the code you sent to me. However I am a new developer and I will or am working with telerik controls most of everyday and I would like to better understand how it work, to avoid having to ask several questions on here. Is there any tutorial that could go over and explain step by step?
0
Princy
Top achievements
Rank 2
answered on 03 Feb 2014, 03:28 AM
Hi Paulo,

Please go through this documentation on Telerik UI for ASP.NET AJAX Documentation to know more about telerik controls and for its working please take a look at the Online Demos.

Thanks,
Princy
0
Paulo
Top achievements
Rank 1
answered on 03 Feb 2014, 04:53 AM
Thank you Princy. The piece of code you sent me was a great help. Also thank you for your last email.
Tags
Grid
Asked by
Paulo
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Paulo
Top achievements
Rank 1
Share this question
or