Get the number of items in remote call

Hello,

I want to catch the number of items in the list view. My listview is has remote data, so i want to catch this number in the listview javascript method actionComplete.

I found in the api documentation the property dataSource of the list view so i tried something like this
function onListComplete() {
            const listView = document.getElementById("idList").ej2_instances[0];
            alert(listView.dataSource);}

But I have no more information about the datasource object. I have tried dataSource.items.length and some others but I didn't succeed.

Can you provide me some code example to have this information?

My goal is to manage display an empty list message. Maybe you have a better way to do this?

Regards,
Laurent 

1 Reply 1 reply marked as answer

SS Sharon Sanchez Selvaraj Syncfusion Team May 27, 2021 06:09 AM UTC

Hi Laurent, 
 
Greetings from Syncfusion Support. 
 
We checked with your query. The data source length of the ListView component can be fetched through the result arguments in the actionComplete event. 
 
Refer to the following code snippet where we have fetched the result’s length and the result data source. 
 
  function onActionComplete(e) { 
        console.log(e.result); 
        console.log(e.result.length); 
    } 
 
Refer to the sample below for your reference. 
 
 
Please get back to us if you need further assistance. 
 
Regards, 
 
Sharon Sanchez S. 


Marked as answer
Loader.
Up arrow icon