We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

How can we make the listbox visible or invisible with one condition?

How can we make the listbox visible or invisible with one condition?

1 Reply

SP Sangeetha Priya Murugan Syncfusion Team August 20, 2019 11:57 AM UTC

Hi Ebi, 
 
Thank you for contacting Syncfusion support. 
 
We have checked your reported requirement “To Hide/Show the ListBox component based on condition” and it can be achievable by using CssClass property as like in the below code example. 
 
Code Example: 
 
<EjsListBox Value=@Value DataSource="@Data" TValue="string[]" @ref="CustomListBox"></EjsListBox> 
 
<EjsButton CssClass="e-flat" IsToggle="true" IsPrimary="true" Content="@Content" @ref="ToggleButton" onclick="OnToggleClick"></EjsButton> 
 
<style> 
    .e-custom-hide{ 
        display:none; 
    } 
</style> 
 
@code{ 
public string[] Value = new string[] { "Hennessey Venom" }; 
public List<object> Data = new List<object> 
{ 
        new { text = "Hennessey Venom", id = "list-01" }, 
        ..// 
    }; 
 
EjsButton ToggleButton; 
EjsListBox<string[]> CustomListBox; 
public string Content = "Hide"; 
public void OnToggleClick(UIMouseEventArgs args) 
{ 
    if (ToggleButton.Content == "Hide") 
    { 
        this.Content = "Show"; 
        CustomListBox.CssClass = "e-custom-hide"; // To hide the ListBox based on the Button text 
         
    } 
    else 
    { 
        this.Content = "Hide"; 
        CustomListBox.CssClass = ""; // To show the ListBox based on the Button text 
    } 
} 
} 
 
 
 
For your convenience, we have prepared the sample that hide/show the listbox based on the button text in a click event. Please find the sample link below. 
 
 
Could you please check the above sample and get back to us with more details, if we have misunderstood your requirement or need further assistance on this. 
 
Regards, 
Sangeetha M 


Loader.
Live Chat Icon For mobile
Up arrow icon