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

Run/Load/?? JQuery/Javascript Code on a RadGrid WebUserControl/EditUserControl (Dumb Question)

4 Answers 133 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Josue
Top achievements
Rank 1
Josue asked on 02 Mar 2011, 05:41 AM
Hi,

I know this is kinda a dumb question and maybe is more related to web development than related to telerik but the question is simple...
I have a WebUserControl or better a description an EditUserControl which is called/referenced from RadGrid everytime someone executes de Edit Command on the RadGrid.
This Radgrid is on page controlled by a Master Page which have three simple basic content place holder (head,body,footer), normally i will just add jquery to the script manager (or this case the radscriptmanager) and start developing normally with jquery.
I know and have read how to use jquery by using the self-calling ($telerik.$) anonymous function but i can fire-up any event, even try to do a simple alert and it wont work, my question is  simpler...

How can i execute javascript/jquery inside a WebUserControl.

Regards

4 Answers, 1 is accepted

Sort by
0
Accepted
Radoslav
Telerik team
answered on 07 Mar 2011, 12:12 PM
Hi Josue,

I tried to reproduce the described issue but to no avail. Every JavaScript or jQuery put into my WebUserControl works as expected. I am sending you a simple example which demonstrates this. Please check it out and let me know what differs in your scenario.
Also keep in mind that if you use the ajax and load the user control dynamically you need to around all scripts with the RadScriptBlock. More information you could find in the following article:
http://www.telerik.com/help/aspnet-ajax/ajxradscriptblockradcodeblock.html

Looking forward for your reply.

Greetings,
Radoslav
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
0
Josue
Top achievements
Rank 1
answered on 16 Mar 2011, 06:34 AM
Thanks thats what i was looking for...

M feel dumb that i miss that part of the documentation..

Best Regards
0
Emmanuel
Top achievements
Rank 1
answered on 09 Jan 2014, 04:04 AM
Hi,
I tried to modified the scrip you provided to make it work with my application:
<telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
        <script type="text/javascript">
            function OnGridCreated(sender, eventArgs) {
                var radgrid = $telerik.$(".radGrid");
                alert("The ID of the RadGrid: " + radgrid[0].id);

                $telerik.$('.textbox').blur(function () {
                    alert('Handler for .blur() called.');

                });
                $telerik.$('.ddl').blur(function () {
                    alert('DDL Changed');
                });
            }
        </script>
    </telerik:RadScriptBlock>

What I'm trying to do is when I select a new value from a dropdownlist (CssClass="dll") in my radgrid, I would like to write that value in a textbox also located in my grid view.
How can I do that?
Thank you
0
Radoslav
Telerik team
answered on 13 Jan 2014, 09:18 AM
Hello Emmanuel,

To achieve the desired functionality you can try using the findElement function in order to find the related textbox control when dropdownlist item is chosen:
$telerik.$('.ddl').blur(function (sender, eventArgs) {
           var masterTable = radgrid.get_masterTableView();
           var textbox = masterTable.get_dataItems()[itemIndex].findElement("textbox");
           // asign selected value to the textbox
 });
More information about findElement you can  find here:
http://www.telerik.com/help/aspnet-ajax/grid-griddataitem-findelement.html

Please give it try and let me know if it helps you.

Regards,
Radoslav
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Tags
Grid
Asked by
Josue
Top achievements
Rank 1
Answers by
Radoslav
Telerik team
Josue
Top achievements
Rank 1
Emmanuel
Top achievements
Rank 1
Share this question
or