0

I need to manipulate the data while its being fetch

    @Override
    public Stream<T> fetch(Query<T, F> query) {
        ...
    }

I found out when runtime, that the data is not all fetched because of lazy loading feature. I need to get all rows when I manipulate them.

How to get all data in sorted/filtered while preserve the lazy loading feature?

EDIT: My case: At my frontend, I have some batch operation that I can select from my grid and I can choose the starting row, from first row or from currently selected row. In vaadin7, I just use firstItemID, lastItemID, prevItemID, nextItemID methods of IndexedContainer to looping through grid rows. In vaadin8, there was no such methods. So I was thinking to add prev and next pointer to my bean, and linking them every time the dataprovider fetching the rows

    @Override
    public Stream<T> fetch(Query<T, F> query) {
        List<T> result = wrapped.fetch(query).collect(Collectors.toCollection(ArrayList::new));
        fakeDataBean prevbean = null;

        for (int i = 1; i <= result.size(); i++) {
            fakeDataBean bean = result.get(i-1);

            bean.setPreviousRow(prevbean);
            if (prevbean!=null) {
                prevbean.setNextRow(bean);
            } else {
                first = bean;
            }

            prevbean = bean;
            if (i==result.size()) {
                last = bean;
            }
        }
        return wrapped.fetch(query);
    }

The problem is DataProvider is fetching only visible rows because of its lazy loading feature.

  • Perhaps you're _attacking_ the problem from a less than optimal angle, (eg: fetching all the data). You're not saying if you're getting it from db or how many rows you could have, but imagine loading 1mil rows :-). Could you please elaborate on your scenario and your need to manipulate them before being available in the UI? – Morfic Jun 16 '17 at 12:20
  • in vaadin7, IndexedContainer there are methods: firstItemID, lastItemID, prevItemID, nextItemID. in vaadin8, there is no method to looping through rows. I just want to implemented them in vaadin8 – William Anthony Jun 17 '17 at 01:47
  • also I can't do that at bean level, because I need them in sorted/filtered by DataProvider – William Anthony Jun 17 '17 at 01:50
  • Please describe your use case. I think it will be more easy to propose a solution then. If you already have all rows fetched at once and just want to show them, then you can use `DataProvider.ofCollection(yourRows)` or the `ofItems` method. – Steffen Harbich Jun 17 '17 at 11:54
  • At my frontend, I have some batch operation that I can select from my grid and I can choose the starting row, from first row or from currently selected row. In vaadin7, I just use firstItemID, lastItemID, prevItemID, nextItemID methods of IndexedContainer to achieve that. In vaadin8, there was no such methods. So I was thinking to add prev and next pointer to my bean, and linking them every time the dataprovider fetching the rows. – William Anthony Jun 19 '17 at 03:16

0 Answers0