Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Client Side Filtering with Pagination on Grid

    Hi,
    I am using smartGWT version "6.1-p20170905". The following use-case is irrespective of browser though i am using chrome.

    I am using ListGrid. I had to activate pagination on this grid. So i used following client side settings on grid to enable it:
    Code:
    [INDENT]grid.setDataPageSize(5);
    grid.setDataFetchMode(FetchMode.PAGED);
    grid.setAutoFetchData(true);
    grid.getDataSource().setClientOnly(true);
    grid.setAutoFitData(Autofit.VERTICAL);
    grid.setAutoFitMaxRecords(5);[/INDENT]
    After doing these changes and server side changes , pagination is working fine.

    On the same screen , i have one Search field on the click of which i do filtering on this criteria using AdvancedCritieria as below:

    Code:
    display.getSearchTextItem().addChangedHandler(event -> {
    AdvancedCriteria criteria = new AdvancedCriteria(OperatorId.OR,
    new Criterion[] { new Criterion("Code", OperatorId.ICONTAINS, input),
    new Criterion("desc", OperatorId.ICONTAINS, input),
    new Criterion("number", OperatorId.ICONTAINS, input),
    new Criterion("address", OperatorId.ICONTAINS, input) });
    grid.filterData(criteria);
    });
    The above filtering was working fine using client side filtering when there was no pagination. After doing pagination related changes, every keypress in Search Text item goes for server hit and filtering does not work.

    Please note when there was no pagination, my DSRequest had FetchMode.BASIC for this grid.

    I want to have pagination and client side filtering enabled on my Grid. Please help.

    Thanks,

    #2
    This is a nonsense line of code that will crash, as the attribute is not allowed to be changed on the fly:

    Code:
    grid.getDataSource().setClientOnly(true);
    Please see the docs for ListGrid.fetchData() for an explanation of when the ListGrid will fetch from the server or perform filtering on the client. You are probably just applying criteria that are less restrictive than the criteria currently on the grid, so a server trip is required. Possibly you need to combine the new criteria with the criteria already on the grid - your call to filterData() replaces the current criteria with your new criteria.

    Comment

    Working...
    X