Related ComboBoxes in Popup GridEditForm

4 posts, 0 answers
  1. Philip Senechal
    Philip Senechal avatar
    152 posts
    Member since:
    Apr 2008

    Posted 03 Nov 2010 Link to this post

    Greetings...

    I'm attempting to implement the code from the Related ComboBoxes demo using a Country/State combination. My issue is that I'm doing so in a Popup GridEditForm Template. I'm running into problems with gaining access to the State combo. In the demo, you are using the PageLoad event and a $find("<%= RadComboBox2.ClientID %>"); statement to set a global variable to be used later. Obviously this isn't an option with the GridEditForm Template.

    Is there a way to gain access to that second ComboBox in the GridEditFormTemplate so I can kick off the requestItems with the value of the first ComboBox?

    Your assistance is much appreciated.
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 04 Nov 2010 Link to this post

    Hello Philip,

    The following code library will help you to achieve your requirement.
     Accessing server controls in a grid template on the client

    Thanks,
    Princy.
  3. Philip Senechal
    Philip Senechal avatar
    152 posts
    Member since:
    Apr 2008

    Posted 04 Nov 2010 Link to this post

    See next post please...
  4. Philip Senechal
    Philip Senechal avatar
    152 posts
    Member since:
    Apr 2008

    Posted 04 Nov 2010 Link to this post

    I actually found a much easier way to do it using the following code...
    <div class="popup_title">
        Physical State:
    </div>
    <div class="popup_content">
        <telerik:RadComboBox ID="dd_unit_phys_st" Skin="Windows7" Font-Size="11px" ShowToggleImage="true"
            OnClientItemsRequested="ItemsLoaded" OnItemsRequested="dd_unit_phys_st_ItemsRequested"
            runat="server" />
    </div>
    <div class="clear">
    </div>
    <div class="popup_title">
        Physical Country:
    </div>
    <div class="popup_content">
        <telerik:RadComboBox ID="dd_unit_phys_co" Skin="Windows7" Font-Size="11px" ShowToggleImage="true"
            OnClientSelectedIndexChanged="LoadStates" runat="server" />
    </div>
    <div class="clear">
    </div>
    <telerik:RadScriptBlock ID="RadScriptBlock4" runat="server">
        <script type="text/javascript">
            function LoadStates(combo, eventArgs) {
                var statesCombo = $find('<%# Container.FindControl("dd_unit_phys_st").ClientID %>');
                var item = eventArgs.get_item();
                statesCombo.set_text("Loading...")
     
                if (item.get_index() > 0) {
                    alert("TEST");
                    statesCombo.requestItems(item.get_value(), false);
                }
                else {
                    statesCombo.set_text(" ");
                    statesCombo.clearItems();
                }
            }
     
            function ItemsLoaded(combo, eventArgs) {
                if (combo.get_items().get_count() > 0) {
                    combo.set_text(combo.get_items().getItem(0).get_text());
                    combo.get_items().getItem(0).highlight;
                }
                combo.showDropDown;
            }
        </script>
    </telerik:RadScriptBlock>

    and the same code behind as before to load the Countries dropdown in the Grid ItemDataBound event and the States dropdown in a ItemsRequested event.

    I can see that I'm getting to my control because "Loading..." appears in the States dropdown, however, instead of bringing back the list of states, it's popping this error message:

    The target ctl00$Content$C000$RadGrid1$ctl00$ctl05$dd_unit_phys_st for the callback could not be found or did not implement ICallbackEventHandler.

    Any suggestions?
Back to Top