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

Accessing radgrid item control from ClientSide

1 Answer 12 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Patrick
Top achievements
Rank 1
Patrick asked on 10 Sep 2013, 07:36 PM
Hi,
 I'm looking to add a javascript function to the "onkeyup" event of a textbox when it's in InsertMode.

In the Code Behind I have:
protected void rgItems_ItemDataBound(object sender, GridItemEventArgs e)
        {
            if (e.Item is GridEditableItem && e.Item.IsInEditMode && rgItems.MasterTableView.IsItemInserted)
            {
                GridEditableItem item = (GridEditableItem)e.Item;
                CheckBox isActive = (CheckBox)item["IsActive"].Controls[0]; //no literal control
                isActive.Checked = true;
 
                TextBox name = item.FindControl("NameTextBox") as TextBox;
                name.Attributes.Add("onkeyup", "filterGrid('"+ name.ClientID + "')");
            }
        }

And in my javascript function I have:
function filterGrid(textBoxID) {
    var grid = $find('<%= rgItems.ClientID %>');
    var textBox = $find(textBoxID);
    var textBox2 = $("#" + textBoxID);
 
 
    createMatchingGrid(grid, textBox.get_textBoxValue());
}


The issue is that "textBox" is null but textBox2 is not.
So the JQuery find works as expected by Telerik's $find does not.
Any ideas?

In the mean time i'll just use JQuery's method.

Thanks,
~Patrick

1 Answer, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 11 Sep 2013, 04:44 AM
Hello,

Please try with the below code snippet.

When you pass the clientID from back-end then you have to use $get.

function filterGrid(textBoxID) {
                debugger;
                var grid = $find('<%= RadGrid1.ClientID %>');
                var textBox = $get(textBoxID);
                var textBox2 = $("#" + textBoxID);
}


Thanks,
Jayesh Goyani
Tags
Grid
Asked by
Patrick
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Share this question
or