Decorate dynamic controls at client - side.

6 posts, 1 answers
  1. Abhijit Shetty
    Abhijit Shetty avatar
    36 posts
    Member since:
    May 2010

    Posted 10 Oct 2012 Link to this post

    Hi,

    I have a scenario where I'm dynamically creating checkbox at client side and need to decorate it using RadFormDecorator.
    For Ex:
    <form id="form1" runat="server">
       <asp:ScriptManager ID="ScriptManager1" runat="server">
               <Scripts>
                   <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
                   <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" />
               </Scripts>
           </asp:ScriptManager>
           <telerik:RadFormDecorator ID="RadFormDecorator1" runat="server" Skin="Default" DecoratedControls="All" />
           <div id="d"></div>
       </form>
       <script type="text/javascript">
           window.onload = function () {
               var cb = document.createElement('input');
               cb.type = 'checkbox';
               document.getElementById('d').appendChild(cb);
               var decorator = $find("<%= RadFormDecorator1.ClientID %>");
               if (decorator) {
                   decorator.decorate(cb, true);
               }
           }
       </script>
    Thanks in advance...
  2. Abhijit Shetty
    Abhijit Shetty avatar
    36 posts
    Member since:
    May 2010

    Posted 10 Oct 2012 Link to this post

    I found out after debugging javascript that instead of passing control to decorate as parameter, we need to pass its container control as parameter.
    In short:Code will be (higlighted in bold)
    <script type="text/javascript">
           window.onload = function () {
               var cb = document.createElement('input');
               cb.type = 'checkbox';
               document.getElementById('d').appendChild(cb);
               var decorator = $find("<%= RadFormDecorator1.ClientID %>");
               if (decorator) {
                   decorator.decorate(cb.parentNode, true);
                        // OR decorator.decorateInput(cb);
               }
           }
       </script>
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Answer
    Niko
    Admin
    Niko avatar
    387 posts

    Posted 15 Oct 2012 Link to this post

    Hello,

    Your observations are quite correct. The decorate method expects as input the container that holds the different controls to be decorated. Please, keep in mind that there can be different kinds of decorated controls, therefore we need just the container.
     If you need to decorate just the checkbox you can use decorateInput and simply send the input to be decorated. Still you should keep in mind that if you choose this approach the checkbox will be decorated unconditionally, i.e. if it has a className it will still be decorated.

    Hope this helps.

    Kind regards,
    Niko
    the Telerik team
    Explore the entire set of ASP.NET AJAX controls we offer here and browse the myriad online demos to learn more about the components and the features they incorporate.
  5. Abhijit Shetty
    Abhijit Shetty avatar
    36 posts
    Member since:
    May 2010

    Posted 16 Oct 2012 Link to this post

    Thanks Niko,
    I have a doubt about response time from telerik group for posts. How soon can i expect reply from you after adding a post. I dont see any response for 3-4 days because of which productivity time gets affected.
    I'm planning to buy product only after testing it on trial but finding it difficult to implement and draw a conclusion because of delay in response.

    Thanks.
  6. Rumen
    Admin
    Rumen avatar
    12849 posts

    Posted 16 Oct 2012 Link to this post

    Hi,

    The forums are considered a community resource and although we closely monitor them, we cannot guarantee a timely response there. That is why in such cases we strongly recommend to use the support ticketing system in your Client.net account.

    Best regards,
    Rumen
    the Telerik team
    Explore the entire set of ASP.NET AJAX controls we offer here and browse the myriad online demos to learn more about the components and the features they incorporate.
  7. Abhijit Shetty
    Abhijit Shetty avatar
    36 posts
    Member since:
    May 2010

    Posted 16 Oct 2012 Link to this post

    Thanks Rumen. I din't knew that!!!
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017