Hello,
For a project we choose to use smartgwt 2.5.
The business case:
- we use a ListGrid that is populated by mean of a smartgwt Datasource (listGrid.setDataSource({our datasource object}).
- On our page, we have a “filter selector” to filter the list.
- For example, if we want to filter on “status”, we do:
Criterion newCriterion = new Criterion(“status”, OperatorId.IEQUALS, “Nieuw”);
listGrid.fetchData(newCriterion);
When we open the page (where we put the ListGrid), 2 solutions (depending on our business cases):
-
We want to display all the items WITHOUT automatically selecting a filter (so, all records are displayed when page starts).
==> NO PROBLEM -
We want to automatically apply a filter when the page is launched.
==> PROBLEM !!
The filter is not applied, or more exactly: all the rows are always displayed and if we try to select an other filter, the list seems to be frozen). It’s like if the rendering of the list became crazy !
So, what I did:
- At the end of the “onModuleLoad” method, I displayed an Alert (for test purpose, just after the “setFilter” call)
==> Alert is displayed and after closing the alert, the filter is WELL applied, and all’s working well.
- OK, so, this is asynchronous, I want to apply the filter when I’m sure that the onModuleLoad is finished, I used a Scheduler, like that:
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
@Override
public void execute() {
setFilter();
}
});
==> Same behavior, doesn’t work
- As I workaround, cause we had to quickly deliver a solution, I did the following:
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
@Override
public void execute() {
Timer t = new Timer() {
@Override
public void run() {
setFilter();
}
};
t.schedule(150);
}
});
==> I used a timer to wait a little bit before setting filter ==> it’s working.
But we don’t like this “timer” solution.
So,
- Has anyone already seen this behavior before ?
- Do you have a solution to be able to filter a ListGrid when module starts ?
Remark: an other solution would to reset the datasource every time we want to set a filter. But this is not a performant solution (back to server) and we would like to use the smartgwt ListGrid features.
Any information is welcome !!
Thanks a lot
Cristophe