Access controls inside a RadGrid row

7 posts, 0 answers
  1. Sonia
    Sonia avatar
    90 posts
    Member since:
    Mar 2012

    Posted 05 Sep 2014 Link to this post

    I have a RadGrid with two GridTemplateColumns and a RadDropDownList in each of them. I would like to show/hide another controls depending on the selection made in both RadDropDownLists when inserting or editing a row.
    I have tried to implement OnClientSelectedIndexChanged however i do not know how to access the rest of controls of the same row to achieve that.

    Any help will be welcome.  
  2. Eyup
    Admin
    Eyup avatar
    3007 posts

    Posted 10 Sep 2014 Link to this post

    Hi Sonia,

    You can achieve this requirement either on client-side or server-side. I'm sending a sample RadGrid web site to demonstrate a client-side implementation. Please run the attached application and let me know if your scenario is different.

    Regards,
    Eyup
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Sonia
    Sonia avatar
    90 posts
    Member since:
    Mar 2012

    Posted 22 Sep 2014 in reply to Eyup Link to this post

    Thank you Eyup, your solution has helped me a lot.

    Apart from hiding the controls, i would like to reset a RadNumericTextBox when calling hideIndefiniteSharing(editForm). This is what i have tried:

    var tbNumPeriods = $telerik.findElement(editForm, "NumPeriods");
    tbNumPeriods.set_value(1);

    However it gives me an error "The object does not accept the property or method 'set_value'"
    What am i missing?

  5. Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    1795 posts

    Posted 24 Sep 2014 Link to this post

    Hello Sonia,

    The issue that you are facing is due to the fact that $telerik.findElement method will return a DOM element corresponding to the control's ID. In order to retrieve the client object of a control from our suite you must use $telerik.findControl method.

    Information on how those two methods work can be found in the following articles:
    Hope this helps.


    Regards,
    Konstantin Dikov
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  6. Sonia
    Sonia avatar
    90 posts
    Member since:
    Mar 2012

    Posted 24 Sep 2014 in reply to Konstantin Dikov Link to this post

    Hello Konstantin,

    $telerik.findControl(editForm, "NumPeriods");

    returns null,

    that is why i tried with findElement.
  7. Sonia
    Sonia avatar
    90 posts
    Member since:
    Mar 2012

    Posted 25 Sep 2014 in reply to Sonia Link to this post

    I find out that
    $telerik.findControl(editForm, "NumPeriods");

    returns null when the RadNumericTextBox NumPeriods is inside table with display property = 'none'

    After extracting the control above the table it returns the RadNumericTextBox control

    The problem now is when i try to set visibility to false it does not work

    var tbNumPeriods = $telerik.findControl(editForm, "NumPeriods");
    tbNumPeriods.set_visible(false);

    why?
                    

     
  8. Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    1795 posts

    Posted 29 Sep 2014 Link to this post

    Hello Sonia,

    The following simple example demonstrates that if a RadNumericTextBox is placed inside a container with display property set to "none", you will still be able to find the control with $telerik.findControl method:
    <script type="text/javascript">
        function pageLoad() {
            var panel1 = document.getElementById("panel1");
            var testInput1 = $telerik.findElement(panel1, "testInput1");
            var numericTextBox = $telerik.findControl(panel1, "RadNumericTextBox1");
            debugger;
        }
    </script>
     
    <div id="panel1" style="display: none;">
        <input id="testInput1" type="text" />
        <telerik:RadNumericTextBox runat="server" ID="RadNumericTextBox1"></telerik:RadNumericTextBox>
    </div>

    However, if RadNumericTextBox is placed in a server control with Visible property set to false, it is expected to not find any nested controls, because they will not be rendered at all.

    If in your scenario you do not have a server control with Visible property set to false, please provide a simplified version of your scenario that replicates the issue.


    Regards,
    Konstantin Dikov
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017