Combobox in RadGrid, accessing and hiding in javascript

5 posts, 1 answers
  1. Wired_Nerve
    Wired_Nerve avatar
    163 posts
    Member since:
    Oct 2007

    Posted 28 Feb 2013 Link to this post

    I have a radcombobox in a grid.. .And after the onSelectedIndexChanged event is fired on the client side I would like to hide the combobox...

    function onSelectedIndexChanged(sender, eventArgs) {
              var selectedItem = eventArgs.get_item();
                     // I do some stuff with the selected item...
            //  Now I would like to hide this radcombobox in the radgrid row...
     
              sender.set_visible(false);   // This did not work...
    }
    This is the GridTemplateColumn the control resides in:
    <telerik:GridTemplateColumn HeaderText="Actions" UniqueName="Actions" AllowFiltering="false"
                          Visible="true">
                          <ItemTemplate>
                              <asp:Label ID="ActionLabel" runat="server" Text="" Visible="false" />
                           <telerik:RadComboBox ID="RadComboBoxActions" runat="server" EmptyMessage="Select Action..."
                                  AutoPostBack="true" Width="155px" OnClientSelectedIndexChanged="onSelectedIndexChanged" />
                          </ItemTemplate>
                          <ItemStyle Width="155px" />
                      </telerik:GridTemplateColumn>
  2. MasterChiefMasterChef
    MasterChiefMasterChef avatar
    152 posts
    Member since:
    Jan 2013

    Posted 28 Feb 2013 Link to this post

    Hi Warren,

    It is very simple to make specific RadControls hide and show on the screen. Simply set the visible property to 'true' or 'false' in the codebehind. Take a look at the demo here:
    http://demos.telerik.com/aspnet-ajax/ajax/examples/common/showingwebcontrols/defaultcs.aspx

    public void RadComboBox1_ItemSelected(Object sender, EventArgs e)
    {
              RadComboBox1.Visible = false;
    }

    Good luck,
    Master Chief
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Wired_Nerve
    Wired_Nerve avatar
    163 posts
    Member since:
    Oct 2007

    Posted 28 Feb 2013 Link to this post

    Unfortunately, it is not that simple because the RadComboBox is dynamically created for each row in the RADGRID (template column) and the ID of the control is not directly known.  Now the  sender, eventArgs  that are supplied to the event handler has a uniqueID value but that does not seem to help me out in this instance...   I have tried using jquery similar to this  $('#' + sender.uniqueID).hide();  but no luck.. 



    If I could do $find('sender.clientid') and hide it that would be great, but that does not seem to work either.. I am sure the solution is VERY simple, but I just don't see it...

  5. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 01 Mar 2013 Link to this post

    Hi,

    Try setting AutoPostBack as false and then hide the combobox using the following javascript.
    JS:
    function OnClientSelectedIndexChanged(sender, args) {
      sender.set_visible(false);
       }

    Thanks,
    Princy
  6. Wired_Nerve
    Wired_Nerve avatar
    163 posts
    Member since:
    Oct 2007

    Posted 01 Mar 2013 Link to this post

    You know I am so use to having to turn ON autopostback I did not even think to look for that.. Once I set AutoPostback to false it worked like a charm!  Wonderful, but frustrating!!!

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