How to disable popup if no data is found, DropDownList / Multiselect

1 Answer 96 Views
DropDownList MultiSelect
Mikko
Top achievements
Rank 1
Mikko asked on 16 Mar 2023, 10:38 AM | edited on 16 Mar 2023, 10:39 AM

Hello,

How do I disable popup if no DropDownList/Multiselect contains no data or filtering does not find any items using html helpers:

    @(
        Html.Kendo().DropDownList()
                  .Name("Testi")
                  .DataTextField("Text")
                  .DataValueField("Value")
                  .BindTo(Source)
     )

If I instantate controls using jQuery I would get this done setting noDataTemplate to false:
$("#Testi").kendoDropDownList({ noDataTemplate: false, ..

On html helpers there is no option to set NoDataTemplate boolean value and setting string value empty or null does not work.

Mikko

1 Answer, 1 is accepted

Sort by
0
Aleksandar
Telerik team
answered on 21 Mar 2023, 05:23 AM

Hi Mikko,

Indeed the HTML Helpers do not expose an overload that takes a boolean as a parameter. Therefore the approaches I can suggest are either initializeing the component using Kendo UI for jQuery or using the HTML Helpers and calling the setOptions method and setting the noDataTemplate to false:

@(
        Html.Kendo().DropDownList()
                  .Name("Testi")
                  .DataTextField("Text")
                  .DataValueField("Value")
                  .BindTo(Source)
     )
<script>
    $('document').ready(function(){
        $("#Testi").getKendoDropDownList().setOptions({
            noDataTemplate:false
        })
    })
</script>

I hope this helps.

Regards,
Aleksandar
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
DropDownList MultiSelect
Asked by
Mikko
Top achievements
Rank 1
Answers by
Aleksandar
Telerik team
Share this question
or