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

EventArgs undefined

1 Answer 157 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
tommy
Top achievements
Rank 1
tommy asked on 01 Oct 2014, 06:35 AM
I have configured my RadGrid to call a client side function and call an AJAX script to insert records into my dB. 
I am successful at calling my Client Side JS function by utilizing the <clientevents onrowclick=RowClick> event.

<ClientEvents OnRowClick="RowClick" />  *** This works but it is not my ideal solution

 I would like to call this function by the execution of the onblur event from a textbox control.

I have tried the code below but I am not having any luck:
<telerik:GridTemplateColumn HeaderText="Qty" AllowFiltering="false" UniqueName="Column2">
<ItemTemplate>
<telerik:RadTextBox ID="qty" runat="server" AutoPostBack="True">
<ClientEvents OnBlur="function(sender,args){RowClick(sender,args)}" />
</telerik:RadTextBox>
</ItemTemplate>
</telerik:GridTemplateColumn>

However, when I execute the Onblur event I get this error:   

JavaScript runtime error: Object doesn't support property or method 'get_id'

I assume that this is due to the fact that it doesn't know the ROW id when inside of the textbox?

Any help is appreciated!

1 Answer, 1 is accepted

Sort by
0
Viktor Tachev
Telerik team
answered on 03 Oct 2014, 12:59 PM
Hello,

If you would like to get the id of a row using the Blur event of a RadTextBox control you could use the following approach. Find the row element that contains the textbox and access its id attribute. You could use jQuery to find the element easier. Check out the code snippets below for illustration:

<telerik:GridTemplateColumn HeaderText="Qty" AllowFiltering="false" UniqueName="Column2">
    <ItemTemplate>
        <telerik:RadTextBox ID="qty" runat="server" AutoPostBack="false">
            <ClientEvents OnBlur="onBlur" />
        </telerik:RadTextBox>
    </ItemTemplate>
</telerik:GridTemplateColumn>

JavaScript:

function onBlur(sender, args) {
    var parentRowId = $telerik.$(sender.get_element()).closest("tr")[0].id;
                     
    alert(parentRowId);
}


Regards,
Viktor Tachev
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Ajax
Asked by
tommy
Top achievements
Rank 1
Answers by
Viktor Tachev
Telerik team
Share this question
or