DropDownList message for no result vs message for data source not loaded yet?

1 Answer 493 Views
ComboBox DropDownList DropDownTree MultiSelect
iCognition
Top achievements
Rank 1
iCognition asked on 31 Aug 2021, 02:21 AM

I have a DropDownList and users are annoyed that whilst the data is loaded it says "No data found." when in fact, the data hasn't been loaded yet - I found this config item:

https://docs.telerik.com/kendo-ui/api/javascript/ui/dropdownlist/configuration/messages.nodata

How do I make one message appear whilst the data source is loading, and another message once the data has loaded (and in fact, there was no data found)

1 Answer, 1 is accepted

Sort by
0
Ivan Danchev
Telerik team
answered on 02 Sep 2021, 04:15 PM

Hello Matt,

I am not sure in what scenario the DropDownList shows its dropdown while loading data. Normally the dropdown remains closed and opens once the response to the request for data is received. Thus the dropdown will show up after the response is received and show either the loaded items or "No data found.", if no items are present in the dataSource. That said, you could use a NoDataTemplate and set "Loading..." to be the text displayed by default. Then in the RequestEnd event handler of the DropDownList DataSource you can check if the dataSource contains no data, and if so, set the noDataTemplate accordingly:

function onDSRequestEnd(e) {
  if(e.sender.data().length == 0) {
    var ddl = $("#dropdownlist").data("kendoDropDownList");
    ddl.setOptions({
      noDataTemplate: 'No data found.'
    });
  }
}

Regards,
Ivan Danchev
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

iCognition
Top achievements
Rank 1
commented on 02 Sep 2021, 11:05 PM

Thanks Ivan, this usually occurs when the user has filtered the dropdown, what would be the best way to revert the noDataTemplate to say "Loading..."  when the user types in a new filter query?
Ivan Danchev
Telerik team
commented on 07 Sep 2021, 02:30 PM

That would be the "Filtering" event, which fires when the user types in the input area.
Tags
ComboBox DropDownList DropDownTree MultiSelect
Asked by
iCognition
Top achievements
Rank 1
Answers by
Ivan Danchev
Telerik team
Share this question
or