Forums

casting object returned from document.getElementById to a valid ASPx control

Last post 2/11/2010 4:21 AM by Andy Tr (DevExpress). 3 replies.
Sort Posts: Previous Next
  • Mikael Nensén

    casting object returned from document.getElementById to a valid ASPx control

    2/8/2010 10:09 AM
    • Not Ranked
    • Joined on 8/30/2008
    • Posts 24

    Hi,

    I've just found myself in a predicament where ClientInstanceName can't be used. I have some ClientSideEvents hooked into ASPxSpinEdit controls that are added to templates in a ASPxGridView, once one of these events are triggered i want to iterate through all the other ASPxSpinEdit controls on the same Row/VisibleIndex. To do this i thought that just iterating and using document.getElemenyById would be sufficient, but the object returned does not support the ASPxClientSpinEdit methods; meaning i can't extract the text/value from the object returned.

    I can't use the ASPxGridView's GetRowValues either because the values in the ASPxSpinEdit controls might have been changed.

    How can i extract the ASPxClientSpinEdit values using only javascript? 

    *Bump 1*

    I'm seriously in a situation where the only thing i have access to is the name of the ASPxClientSpinEdit in a loop, is there any way for me to get the ASPxClientSpinEdit object using the name in a string format?

    Is there no method where i can send in the ClientInstanceName and get a handle to the ASPxClientSpinEdit control?

    for (var x = 0; x < numColumns; x++) {
        if (ASPxGridViewRows.GetColumn(x).visible) {
            var controlId = 'ctl00......_ASPxSpinEdit' + x;
            // The following does not return the ASPxClientSpinEdit object, it would be great if there was a DevExpress equivalent method where i could pass in
            // the ClientInstaneName and get a handle to the control
            document.getElementById(controlId).SetReadOnly(false);
        }
    }

  • Andy Tr (DevExpress)

    Re: casting object returned from document.getElementById to a valid ASPx control

    2/10/2010 4:10 AM
    • Top 50 Contributor
    • Joined on 5/7/2007
    • Posts 688

    Hello Mikael,

    If you know the unique client identifier of an HTML element that is the top element representing our control within the page (in your case, you compose this identifier manually and assign it to the 'controlId' variable), you can access our client control object as follows:

    var editor = ASPxClientControl.GetControlCollection().Get(controlId);

     

    It seems that in your scenario, you can try adopting the approach used in the following CodeCentral examples:

    http://search.devexpress.com/?q=access+manipulate+control+in+template+on+client&p=T4|P5|0&d=16

    Thanks,
    R&D, ASP.NET Team, DevExpress
    Andrew

    P.S. This is a peer-to-peer forum. For technical support, contact our Support Team directly at http://www.devexpress.com/Support/Center/ to get a guaranteed reply within a business day.
  • Mikael Nensén

    Re: casting object returned from document.getElementById to a valid ASPx control

    2/10/2010 4:36 AM
    • Not Ranked
    • Joined on 8/30/2008
    • Posts 24

     Hi Andrew, thanks for the reply!

    I chose to set unique ClientInstanceNames for the controls on the server-side by hooking into the ASPxGridView's HtmlDataCellPrepared-event and then in a javascript loop use the "window[...]" to get the handles to the client side instances of the controls :D

    for (var x = 1; x < numColumns; x++) {
        var id = 'ASPxSpinEditCustomerAccounts_' + y + '_' + x;
        var aspxSpinEdit = window[id];
        ...
    }

    The "var editor = ASPxClientControl.GetControlCollection().Get(id)" works great as well! I might use your solution instead depending on how heavy the GetControlCollection() is performance/memory wise?

  • Andy Tr (DevExpress)

    Re: casting object returned from document.getElementById to a valid ASPx control

    2/11/2010 4:21 AM
    • Top 50 Contributor
    • Joined on 5/7/2007
    • Posts 688

    Hello Mikael,

    The implementation of the GetControlCollection method is based on the Hash object, and so, it is designed to be very high-performance. We widely use the GetControlCollection method internally implementing our service JavaScript logic.

    So, it seems that you can rely upon this method in your scenario with no worry.

    Thanks,
    R&D, ASP.NET Team, DevExpress
    Andrew

    P.S. This is a peer-to-peer forum. For technical support, contact our Support Team directly at http://www.devexpress.com/Support/Center/ to get a guaranteed reply within a business day.
More from DevExpress
Live Chat
Have a pre-sales question?
Need assistance with your evaluation?
We are here to help.
Chat is one of the many ways you can contact members of the DevExpress Team. We are available Monday-Friday between 8:30am and 5:00pm Pacific Time.
If you need additional product information, require pre-sales assistance, or want help with your order, write to us at info@devexpress.com or call us at
+1 (818) 844-3383.