LazyList Viritin MGrid

Hi everybody! )

​I try use a LazyList from Viritin add-on and i watch a strange behevior.
My realization of LazyList data provider fine displayed with MTable, but if i use MGrid that generate many a same queries. (0-45/45-90) and again, and again… )
Please, anybody know what is it?

Hi,

Grid makes bit more random access to the backend than Table and if the cache is missed, it will case nasty iteration (and more backend access). There is an idea how this can probably be worked around, but in the mean time, if you cannot use MTable, try using a larger page size for LazyList (or just directly to MTable). A Java 6 style code example below:

        final long pageSize = 200;

        MGrid<Person> g = new MGrid<Person>(
                new LazyList.PagingProvider<Person>() {

                    @Override
                    public List<Person> findEntities(int firstRow) {
                        return Service.findAll(firstRow, pageSize);
                    }
                },
                new LazyList.CountProvider() {

                    @Override
                    public int size() {
                        return (int) Service.count();
                    }
                },
                (int) pageSize
        
        );
        return g;

cheers,
matti

Matti, you a genius!!
Thats work fine!
Thank you for response!!

Hi Matti,

I tried MGrid and I got the strange behaviour. The Mgrid shows all columns and no data. I tested backend which returns right data(2000 rows). PAGESIZE=100. What is wrong ?

grid = new MGrid<>(DocuMetaBO.class);
grid.lazyLoadFrom(
(firstRow, asc, sortProperty) → presenter.findAllBy(firstRow, asc, sortProperty,PAGESIZE),
() → presenter.count(), PAGESIZE)
.withProperties(“alive”);

This is output
26512.png

Seems weird. Hard to say what goes wrong with that codes snippet, which seems just fine to me. Could you try to create a reduced test case where the issue can be reproduced?

cheers,
matti