user1485841
user1485841

Reputation: 31

How can I send the Grid Filter parameters in my RequestBuilder in Ext GWT?

The paging function, and a local filtering is perfect, but i need the REMOTE filter, and i wanna sending the filters parameter to the request method.

Thx!

I have this code:

String path =  GWT.getHostPageBaseURL() + (Examples.isExplorer() ? "" : "../../" ) + "backend/index.php?action=getLines";  

RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, path);  
HttpProxy<String> proxy = new HttpProxy<String>(builder);  

JsonPagingLoadResultReader<PagingLoadResult<ModelData>> reader = new JsonPagingLoadResultReader<PagingLoadResult<ModelData>>(type);  

final PagingLoader<PagingLoadResult<ModelData>> loader = new BasePagingLoader<PagingLoadResult<ModelData>>(proxy,  
    reader);

[...]


NumericFilter sorszamFilter = new NumericFilter("Sorszam");

StringFilter nevFilter = new StringFilter("Nev");

DateFilter datumFilter = new DateFilter("Datum");
NumericFilter szamFilter = new NumericFilter("Szam");

GridFilters filters = new GridFilters();
filters.setLocal(true);
filters.addFilter(sorszamFilter);
filters.addFilter(nevFilter);
filters.addFilter(datumFilter);
filters.addFilter(szamFilter);

//example
sorszamFilter.addListener(Events.Update, new Listener<FilterEvent>() {
    @Override
    public void handleEvent(FilterEvent be) {
        ???
    }

});

[...]

final PagingToolBar toolBar = new PagingToolBar(10);  
toolBar.bind(loader);  

loader.load(0, 10); 

Upvotes: 1

Views: 1253

Answers (1)

Marek Dec
Marek Dec

Reputation: 964

It looks like the BasePagingLoader can get be customized using a loadConfig object. The loadConfig should be an Object of a ModelData type and more specifically a PagingLoadConfig. Create a new loadConfig using the

final ModelData loadConfig = (ModelData) ((BasePagingLoader).loader).newLoadConfig();

method. Then force the loader to use this loadConfig:

((BasePagingLoader).loader).useLoadConfig(loadConfig);

loadConfig should be a mutable instance of a ModelData. That is why you can add new properties to it using the

loadConfig.set("selectedFilter", "what_ever_you_like_here")
loadConfig.set("direction", "ASC");

This should be done in place of the question marks you put and should force the HttpProxy to add whatever you set to the loadConfig properties. (see the HttpProxy#generateUrl method for reference on how the request is build with an aid of a loadConfig). Then you'll have to process the request correspondingly on server-side. I'm assuming you use GXT 2.2.x, and honestly I haven't compiled it, hope it works fine.

Upvotes: 1

Related Questions