ListView Display Message when empty

Hi,


I have a ListView populated by a custom adaptor and I want to display a message when there are no entites. How can I accomplish that?


My ListView looks like this:

<SfListView TValue="Entity" HeaderTitle="Title" ShowCheckBox="false" ShowHeader="true" Height="75vh/*")" Query="new Query().Where(nameof(EntityList.Id), nameof(Operator.Equal).ToLowerInvariant(), currentEntity?.Id)">


    <SfDataManager AdaptorInstance="@typeof(SimpleODataAdaptor<ServiceOrder>)" Adaptor="Adaptors.CustomAdaptor" />


    <ListViewFieldSettings TValue="Entity" Id="@nameof(Entity.Id)" Text="@nameof(Entity.Title)" />


    <ListViewTemplates TValue="Entity" >


        <Template>


            ...


        </Template>


    </ListViewTemplates>


</SfListView>



Best regards

Daniel



6 Replies 1 reply marked as answer

SS Sharon Sanchez Selvaraj Syncfusion Team June 18, 2021 02:31 PM UTC

Hi Daniel, 
 
Greetings from Syncfusion Support. 
 
We checked with your reported query and have prepared a ListView sample similar to the provided code. 
 
Using the Created event of ListView, the given scenario can be achieved. 
 
Refer to the below code snippet. 
 
public void created() 
    { 
        if (serviceAdapter.Entities.Count() == 0) 
        { 
            msg = "List Items are empty"; 
        } 
    } 
 
Refer to the sample. 
 
 
If we have misunderstood, kindly elaborate on your exact use case scenario to guide you in a better way. 
 
Regards, 
 
Sharon Sanchez S. 
 



DA Daniel June 21, 2021 09:24 AM UTC

Hi,

thank you for your help but that's not really what I was looking for.


Clarification: I have this ListView with a given height of 50vh and I want to display the message in the middle of the ListView. I also cannot use the Entites property of the custom adaptor directly because the ListView also has a where Query. How can I achieve that under the given circumstances?

Best regards

Daniel



SS Sharon Sanchez Selvaraj Syncfusion Team June 22, 2021 01:01 PM UTC

Hi Daniel, 


We are currently validating your reported scenario to check whether empty data source is present in ListView. We will provide further validation details within three business days on June 25th , 2021.
 
 
Regards, 
 
Sharon Sanchez S. 



SS Sharon Sanchez Selvaraj Syncfusion Team June 28, 2021 12:00 PM UTC

Hi Daniel, 
  
In order to check with the number of items through the Query attribute of ListView, OnActionComplete event can be used. This event helps in returning the resultant count. Unfortunately, as we don’t have support for this as of now, we have considered this as a bug from our end. 
  
The fix for this issue will be included in third weekly patch release of July 2021. 
  
Please track the below feedback link to know the status of this issue. 
  
  
Please get back to us if you need further assistance. 
  
Regards, 
  
Sharon Sanchez S. 
  



Marked as answer

DA Daniel June 28, 2021 12:13 PM UTC

Hi,


great, thank you very much for your help.


Best regards

Daniel



SP Sowmiya Padmanaban Syncfusion Team June 29, 2021 09:57 AM UTC

Hi Daniel,

Thanks for the update.

We will update you with the details once the release rolled out.

We appreciate your patience.

Regards,
Sowmiya.P



Loader.
Up arrow icon