blazor ListView paging

How to implement Listview Paging


3 Replies 1 reply marked as answer

SS Sivakumar ShunmugaSundaram Syncfusion Team July 1, 2022 01:38 PM UTC

Hi Arrebatrans,


Greetings from Syncfusion support.


We have validated your reported query in the Blazor ListView component. As per the request we have prepared a simple sample of Blazor ListView component to meet your requirement. In this sample we have loaded the list items dynamically when clicking the pager control. We have attached the modified sample for your reference.


Refer the below code snippet.

[Index.razor],

 

<SfListBox TValue="string[]" TItem="VehicleData" Query="@DataQuery">

    <ListBoxFieldSettings Text="Text" Value="Id" />

    <SfDataManager @ref="DataManagerRef" AdaptorInstance="@typeof(CustomAdaptor)"

                   Adaptor="Adaptors.CustomAdaptor">

    </SfDataManager>

</SfListBox>

<SfPager PageSize="1" TotalItemsCount="3" PageChanged="click">

</SfPager>

@code{

...

    public void click(PageChangedEventArgs args)

    {

        DataQuery = new Query().Skip((int)(3 * (args.CurrentPage) - 1)).Take(3);

    }

 

    public class CustomAdaptor : DataAdaptor

    {

        // Performs data Read operation

        public override object Read(DataManagerRequest dm, string key = null)

        {

            IEnumerable<VehicleData> DataSource = Vehicles;

            int count = DataSource.Cast<VehicleData>().Count();

            DataSource = DataOperations.Execute<VehicleData>(DataSource, dm);

            return dm.RequiresCounts ? new DataResult() { Result = DataSource, Count = count } : (object)DataSource;

        }

    }

}


Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/BlazorApp201406844131.zip


Please check the attached sample and get back to us if you need any further assistance.


Regards,

Sivakumar S


Marked as answer

MI Mike-E August 27, 2022 04:59 PM UTC

Super awesome!  Thank you for posting this question and for the answer/solution.  Exactly what I was looking for.



IL Indhumathy Loganathan Syncfusion Team August 29, 2022 07:26 AM UTC

Hi Mike,


We are glad that the posted solution was helpful for you. Please get back to us if you need any further assistance.


Regards,

Indhumathy L


Loader.
Up arrow icon