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

Get radwindow object from element in contenttemplate

3 Answers 318 Views
Window
This is a migrated thread and some comments may be shown as answers.
ToltingColtAcres
Top achievements
Rank 2
Veteran
Iron
ToltingColtAcres asked on 09 Jun 2020, 09:59 AM

Is there a way to determine the parent radwindow of a rad button contained in a contenttemplate in client-side javascript?

e.g. if I have two radwindows, each with a radbutton, and each radbutton calls a common OnClientClicking event, is there a way to determine the parent window from the button object in the common code?

 

<telerik:radWindow runat="server" ID="radwindow1">
 <contenttemplate>
  <telerik:radbutton id="radbutton1" runat="server" onclientclicking="CommonFunction" />
 </contenttemplate>
</telerik:radwindow>
<telerik:radWindow runat="server" ID="radwindow2">
 <contenttemplate>
  <telerik:radbutton id="radbutton2" runat="server" onclientclicking="CommonFunction" />
 </contenttemplate>
</telerik:radwindow>
 
<script>
function CommonFunction(button, eventArgs) {
 var radWindow = ...how to determine which radwindow from the button element? ...
}
</script>

3 Answers, 1 is accepted

Sort by
0
Vessy
Telerik team
answered on 12 Jun 2020, 09:28 AM

Hi Michael,

There are several ways to getr access to a parent RadWindow, I will list them below so you can choose th eone that its your scenario the best:

  1. You can pass custom arguments (e.g. the id of the parent window) to the button's click handler like demonstrated here
  2. You can get the Id of the window through the closest parent of the button, having class ".RadWindow"
                    var parentId = button.get_element().closest(".RadWindow").id;
                    var radWindow = $find(parentId.substring(parentId.indexOf("_") + 1))
  3. You can keep the id of the window in the button's value field and access it after that
    <telerik:RadButton ID="radbutton1" runat="server" OnClientClicking="CommonFunction" Value="radwindow1" />
    
    var radWindow_2 = $find(button.get_value());
  4. You can place the windows into a Radwindowmanager and use its "get"
    var radWindow = GetRadWindowManager().getActiveWindow();

Regards,
Vessy
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
ToltingColtAcres
Top achievements
Rank 2
Veteran
Iron
answered on 13 Jun 2020, 06:07 AM
Thanks Vessy, I had been using option #2, I just wasn't sure if there was an easier way to do it. Appreciate the response.
0
Vessy
Telerik team
answered on 16 Jun 2020, 03:57 PM

Hi,

You are welcome, Michael :) I can confirm that you are on the right way.

Regards,
Vessy
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
Tags
Window
Asked by
ToltingColtAcres
Top achievements
Rank 2
Veteran
Iron
Answers by
Vessy
Telerik team
ToltingColtAcres
Top achievements
Rank 2
Veteran
Iron
Share this question
or