Hey there
We’re setting up a grid where the user is able to filter items which are related to brands.
One filter parameter is selecting a brand via a combobox, the other is typing in chars of the title of items.
The view is a PolymerTemplate.
What we got so far is:
//Fetch grid from client: remember, children are not populated to server side
@Id("grid")
private Grid<SearchItem> grid;
private DataProvider<SearchItem, SearchItemParams> searchItemDataProvider;
private ConfigurableFilterDataProvider<SearchItem, Void, SearchItemParams> searchItemWrapper;
…
this.searchItemDataProvider = DataProvider.fromFilteringCallbacks(query -> {
SearchItemParams filter = query.getFilter().orElse(null);
if(filter == null) {
filter = new SearchItemParams(null, null);
}
final Flux<SearchItem> items = this.itemStorageWebClient.post().uri(this.itemServiceSearchEndpoint)
.accept(MediaType.APPLICATION_STREAM_JSON)
.contentType(MediaType.APPLICATION_STREAM_JSON)
.body(BodyInserters.fromPublisher(Mono.just(filter), SearchItemParams.class))
.exchange()
.log()
.flatMapMany(clientResponse -> clientResponse.bodyToFlux(SearchItem.class));
return items.log().toStream();
}, query -> {
//@todo add endpoint + x-total-count header for getting number of items
SearchItemParams filter = query.getFilter().orElse(null);
if(filter == null) {
filter = new SearchItemParams(null, null);
}
final Flux<SearchItem> items = this.itemStorageWebClient.post().uri(this.itemServiceSearchEndpoint)
.accept(MediaType.APPLICATION_STREAM_JSON)
.contentType(MediaType.APPLICATION_STREAM_JSON)
.body(BodyInserters.fromPublisher(Mono.just(filter), SearchItemParams.class))
.exchange()
.log()
.flatMapMany(clientResponse -> clientResponse.bodyToFlux(SearchItem.class));
return items.count().log().block().intValue();
});
…
this.searchItemWrapper = this.searchItemDataProvider.withConfigurableFilter();
this.grid.setDataProvider(this.searchItemWrapper);
/*
* workaround to get data into the columns which are defined in the polymer html.
* in polymer in the column templates, the data is available via "colx"
*/
//col0
this.grid.addColumn(SearchItem::getId);
//col1
this.grid.addColumn(SearchItem::getTitle);
SearchItem and SearchItemParams are just tiny pojo’s containing an id, a title and a brand.
As the page loads, the brand-combobox gets filled with all available brands.
When the user selects a brand
SearchItemParams params = new SearchItemParams(null, brand.getBrand());
this.searchItemWrapper.setFilter(params);
the filter got set.
At this point we’re facing the problem that in the client-side of the grid (in gridConnector.js on line 258)
let items = cache[page]
;
for (let j = 0; j < items.length; j++) {
item is undefined because somehow “page” is 1 (not 0 as expected) and the cache has the length 1. (See screenshot)
The item count of 2258 for the selected brand is correct also both flux (data + count).
If i select a brand which got less than 50 items, everything works as expected (page = 0).
Is this a bug? I hope my description of the problem is somehow comprehensible
Btw: We are using flow beta 17 and grid 5.0.0
Thanks for your time