This is a migrated thread and some comments may be shown as answers.

Combobox in RadGrid, accessing and hiding in javascript

4 Answers 301 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Wired_Nerve
Top achievements
Rank 2
Wired_Nerve asked on 28 Feb 2013, 07:49 PM
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>

4 Answers, 1 is accepted

Sort by
0
MasterChiefMasterChef
Top achievements
Rank 2
answered on 28 Feb 2013, 10:54 PM
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
0
Wired_Nerve
Top achievements
Rank 2
answered on 28 Feb 2013, 11:10 PM
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...

0
Accepted
Princy
Top achievements
Rank 2
answered on 01 Mar 2013, 07:59 AM
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
0
Wired_Nerve
Top achievements
Rank 2
answered on 01 Mar 2013, 02:38 PM
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!!!

Tags
ComboBox
Asked by
Wired_Nerve
Top achievements
Rank 2
Answers by
MasterChiefMasterChef
Top achievements
Rank 2
Wired_Nerve
Top achievements
Rank 2
Princy
Top achievements
Rank 2
Share this question
or