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

Visible Javascript Multiselect

1 Answer 128 Views
MultiSelect
This is a migrated thread and some comments may be shown as answers.
gonzalez
Top achievements
Rank 1
Veteran
gonzalez asked on 30 May 2020, 01:32 AM

there is any way to set visible or invisible in the control through javascript?

there is a method set_enabled, but I want to hide the control

I've tried with querySelector in the event onClientLoad

sender._element.querySelector('.RadMultiSelect');

but the resul is null

thanks

1 Answer, 1 is accepted

Sort by
0
Doncho
Telerik team
answered on 03 Jun 2020, 03:03 PM

Hello,

You need to get a reference to the wrapper element of the rendered by the RadMultiSelect HTML structure and set it a 'display: none' style.

Here is an approach using jQuery you can try:

  1. Use the client OnLoad event listener to get a reference to a certain RadMultiSelect Control and get its respective html wrapper element. Create a jQuery object of the referenced HTML element and use the jQuery .hide()/.show() functions to set its visibility.
    JavaScript
    var $multiSelectWrapper;
    function clientload(sender, args) {
        var el = sender.get_element();
        $multiSelectWrapper = $(el.parentElement);
    }
    Markup declaration
    <telerik:RadMultiSelect ID="RadMultiSelect1" runat="server">
        <ClientEvents OnLoad="clientload" />
    </telerik:RadMultiSelect>
  2. Hide the RadMultiSelect using JavaScript. Sample using RadButton OnClientClick:
    Markup:
    <telerik:RadButton ID="RadButton1" runat="server" Text="hide" AutoPostBack="false" OnClientClicked="clientClicked"></telerik:RadButton>
    JavaScript
    function clientClicked(sender, args) {
        $multiSelectWrapper.hide();
    }

 

Rendered HTML:

 

I hope this will help

Kind regards,
Doncho
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
Tags
MultiSelect
Asked by
gonzalez
Top achievements
Rank 1
Veteran
Answers by
Doncho
Telerik team
Share this question
or