ListView hideItem/removeItem not working when having ListViewTemplates/Template
Hi team,
The ListView component on Blazor is not doing anything when we try to remove or to hide an item when it has a Template.
An example of how to do this will be appreciated.
Thanks
SIGN IN To post a reply.
3 Replies
SP
Sowmiya Padmanaban
Syncfusion Team
March 13, 2020 09:42 AM UTC
Hi Ernesto,
We have checked your attached query. We suspect that your requirement is to remove/hide an item from ListView component. Yes, it is possible to achieve in ListView component.
In ListView component, we have provided a method RemoveItem() and HideItem() method.
RemoveItem -It is used to remove an item from the ListView and DOM.
HideItem - It is used to remove an item from the ListView.
Note: By default, both this method will work based on the fields loaded in the ListView component. So, to remove or hide an LI item, we need to provide the fields of the data source as arguments to these methods. For this purpose, we need to declare ListViewFieldSettings tag element and need to add the data source fields attributes to the list views mapper fields.
Refer the below code snippet.
|
<EjsListView ID="List" @ref="list"
DataSource="ListData"
HeaderTitle="Contacts"
ShowHeader="true"
CssClass="e-list-template"
Width="350"
SortOrder="Syncfusion.EJ2.Blazor.Lists.SortOrder.Ascending">
<ListViewFieldSettings Id="Id" Text="Name"></ListViewFieldSettings>
<ListViewTemplates>
<Template>
</Template>
</ListViewTemplates>
</EjsListView>
public void RemoveItem()
{
DataModel data1 = new DataModel { Id = "1", };
this.list.RemoveItem(data1);
}
public void HideItem()
{
DataModel data2 =
new DataModel { Id = "2" };
this.list.HideItem(data2);
} |
For your reference, we have prepared a sample.
Please let us know, if you have any concerns.
Regards,
Sowmiya.P
EL
Ernesto Leyva
March 13, 2020 03:12 PM UTC
Awesome, it works, all I needed to do was:
<ListViewFieldSettings Id="Id" Text="Name"></ListViewFieldSettings>
Thanks
SP
Sowmiya Padmanaban
Syncfusion Team
March 16, 2020 06:11 AM UTC
Hi Ernesto,
Most Welcome. We are happy to hear that your issue has been resolved. Please contact us, if you need any help from us. We will be happy to help you
Regards,
Sowmiya.P
SIGN IN To post a reply.
- 3 Replies
- 2 Participants
-
EL Ernesto Leyva
- Mar 12, 2020 11:22 PM UTC
- Mar 16, 2020 06:11 AM UTC