Get radwindow object from element in contenttemplate

4 posts, 0 answers
  1. ToltingColtAcres
    ToltingColtAcres avatar
    113 posts
    Member since:
    Nov 2010

    Posted 09 Jun 2020 Link to this post

    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>
  2. Vessy
    Admin
    Vessy avatar
    2369 posts

    Posted 12 Jun 2020 Link to this post

    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.
  3. ToltingColtAcres
    ToltingColtAcres avatar
    113 posts
    Member since:
    Nov 2010

    Posted 13 Jun 2020 in reply to Vessy Link to this post

    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.
  4. Vessy
    Admin
    Vessy avatar
    2369 posts

    Posted 16 Jun 2020 Link to this post

    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.
Back to Top