PDA

View Full Version : Issue with ListFilter display for remote sorting



dxdev
23 Jul 2015, 11:06 PM
Using the following versions:
- GWT 2.6.1
- GXT 3.1.1

I have the Companygrid with empName as one of its column. I was trying to add remoterfilter in this column. I want empName(s) to be displayed in the filter's ListMenu and empId(s) to be sent to service for filtering. Here is the code snippet for what I was trying to do.


EmployeeProperties employeeProperties = GWT.create(EmployeeProperties .class);

final ListStore<EmployeeModel> employeeStore= new ListStore<EmployeeModel>(employeeProperties.empId());
employeeStore.addAll(getEmployees()));

ListFilter<CompanyModel , EmployeeModel> employeeFilter= new ListFilter<CompanyModel , EmployeeModel>(new ValueProvider<CompanyModel , EmployeeModel>() {

@Override
public EmployeeModel getValue(CompanyModel object) {
return null;
}

@Override
public void setValue(CompanyModel object, EmployeeModel value) {}

@Override
public String getPath() {
return "empName";
}
}, employeeStore);
employeeFilter.setUseStoreKeys(true);

GridFilters<CompanyModel > filters = new GridFilters<CompanyModel >(companyLoader);
filters.initPlugin(grid);
filters.setLocal(false);
filters.addFilter(employeeFilter);

Form the above code I was able to send empId(s) that are selected in the filter to the server, but am facing difficulties in displaying the empName in the filter's ListMenu. I remember the earlier versions of GXT had listFilter.setDisplayProperty() but that is missing in GXT 3.x. So is there any alternate for this now ? I just want to know how to display empName in ListMenu.

Any help is much appreciated. :)

dxdev
25 Jul 2015, 2:54 AM
Any one got a chance to look into this ??

Andreas Samjeske
27 Jul 2015, 12:39 AM
You've got to pimp the ValueProvider applied to ListFilter.

dxdev
27 Jul 2015, 10:41 PM
Hi ,

I tried setting EmployeeModel in the valueProvider as below



ListFilter<CompanyModel, EmployeeModel> employeeFilter = new ListFilter<CompanyModel, EmployeeModel>(new ValueProvider<CompanyModel, EmployeeModel>() {
@Override
public EmployeeModel getValue(CompanyModel compModel) {
EmployeeModel eModel = getNewEmpModel();
eModel.setEmpName(compModel.getEmpName());
eModel.setEmpId(compModel.getEmpId());
return eModel;
}


@Override
public void setValue(CompanyModel compModel, EmployeeModel eModel) {
compModel.setEmpName(eModel.getEmpName());
compModel.setEmpId(eModel.getEmpId());
}


@Override
public String getPath() {
return "empName";
}
}, employeeStore);


Not sure what I am missing here, Any help much appreciated.