Hi,
I'm using smartGWT Pro 4.0. Can you explain how I can use a case insensitive filter in ListGrid?
I’ve tried to reproduce showcase example http://www.smartclient.com/smartgwt/showcase/#grid_sortfilter_filter. Filter is working correctly (case insensitive) while number of rows less then 75. If rows more then 75 then filter works as case sensitive.
DataSource, name is CustomerView.ds.xml:
CustomerView.ds.js:
Creating ListGrid:
I use following code to fetching data:
Console logs:
Thanks
I'm using smartGWT Pro 4.0. Can you explain how I can use a case insensitive filter in ListGrid?
I’ve tried to reproduce showcase example http://www.smartclient.com/smartgwt/showcase/#grid_sortfilter_filter. Filter is working correctly (case insensitive) while number of rows less then 75. If rows more then 75 then filter works as case sensitive.
DataSource, name is CustomerView.ds.xml:
Code:
<DataSource dbName="Mysql" tableName="CustomerView" ID="CustomerView" serverType="sql" > <operationBindings> <operationBinding requiresRole="Customerfetch" operationType="fetch" /> </operationBindings> <fields> <field name="CustomerID" type="integer"></field> <field name="CustomerFName" length="50" type="text"></field> <field name="CustomerLName" length="50" type="text"></field> <field name="CustomerTel1" length="50" type="text"></field> <field name="CustomerEmail" length="250" type="text"></field> <field name="CustomerCanContact" type="integer"></field> <field name="TierName" length="100" type="text"></field> <field name="CustomerPointBalance" type="integer"></field> </fields> </DataSource>
Code:
var CustomerView = { allowAdvancedCriteria:true, ID:"CustomerView", serverType:"sql", fields:[ { name:"CustomerID", type:"integer", primaryKey:true }, { name:"CustomerFName", length:50, type:"text", title:"First Name" }, { name:"CustomerLName", length:50, type:"text", title:"Last Name", sort:true }, { name:"CustomerEmail", length:250, type:"text", title:"Email" }, { name:"CustomerTel1", length:50, type:"text", title:"Telephone" }, { name:"CustomerPointBalance", type:"integer", title:"Points" }, { name:"CustomerCanContact", type:"boolean", title:"Can Contact" }, { name:"TierName", length:100, type:"text", group:true, hidden:true } ] }
Code:
private void drawListGrid() { // TODO add autoDisplayField to primField boolean isNew = listGrid == null; if (isNew) { listGrid = new ListGrid(); listGrid.setHeight100(); listGrid.setWidth100(); listGrid.setCanEdit(false); listGrid.setShowFilterEditor(this.autoFetch); listGrid.setDataSource(getDataSourceView()); listGrid.setAlternateRecordStyles(true); listGrid.setDataFetchMode(FetchMode.PAGED); String fieldWidth = ((int) (100 / getDataSourceView().getFields().length)) + "%"; List<ListGridField> listGridFields = new ArrayList<ListGridField>(); for (int i = 0; i < getDataSourceView().getFields().length; i++) { final DataSourceField field = getDataSourceView().getFields()[i]; ListGridField lgf = new ListGridField(field.getName()); listGridFields.add(lgf); } ListGridField[] lgf = new ListGridField[listGridFields.size()]; lgf = listGridFields.toArray(lgf); listGrid.setFields(lgf); this.addMember(listGrid); listGrid.setFilterOnKeypress(true); listGrid.setAutoFetchData(true); } }
Code:
public void fetch() { if (fetchLocks.isEmpty()) { if (listGrid != null) { if (extraCriteria.isEmpty()) { listGrid.fetchData(criteria, new DSCallback() { @Override public void execute(DSResponse response, Object rawData, DSRequest request) { if (response.getStatus() == 0) { Record[] data = response.getData(); RecordList filteredData = new RecordList(data); listGrid.setData(filteredData); } listGrid.invalidateCache(); } }); } else { getDataSourceView().filterData(criteria, new DSCallback() { @Override public void execute(DSResponse response, Object rawData, DSRequest request) { if (response.getStatus() == 0) { Record[] data = response.getData(); RecordList filteredData = new RecordList(); for (Record r : data) { for (Entry<String, Set<String>> crit : extraCriteria.entrySet()) { String val = r.getAttribute(crit.getKey()); if (val != null) { if (crit.getValue().contains(val)) { filteredData.add(r); break; } } } } listGrid.setData(filteredData); } } }); } } } }
Code:
[java] === 2014-01-30 13:20:09,855 [l0-4] DEBUG DSRequest - Caching instance 30 of DS CustomerView from DSRequest.getDataSource() [java] === 2014-01-30 13:20:09,856 [l0-4] DEBUG RPCManager - Request #1 (DSRequest) payload: { [java] criteria:{ [java] CustomerFName:"alex" [java] }, [java] operationConfig:{ [java] dataSource:"CustomerView", [java] operationType:"fetch", [java] textMatchStyle:"substring" [java] }, [java] startRow:0, [java] endRow:75, [java] sortBy:[ [java] "CustomerLName" [java] ], [java] componentId:"isc_ListGrid_0", [java] appID:"builtinApplication", [java] operation:"CustomerView_fetch", [java] oldValues:{ [java] CustomerFName:"alex" [java] } [java] } [java] === 2014-01-30 13:20:09,856 [l0-4] DEBUG DeclarativeSecurity - Processing security checks for DataSource null, field null [java] === 2014-01-30 13:20:09,856 [l0-4] DEBUG DeclarativeSecurity - DataSource CustomerView is not in the pre-checked list, processing... [java] === 2014-01-30 13:20:09,856 [l0-4] DEBUG AppBase - [builtinApplication.CustomerView_fetch] No userTypes defined, allowing anyone access to all opera tions for this application [java] === 2014-01-30 13:20:09,857 [l0-4] DEBUG AppBase - [builtinApplication.CustomerView_fetch] No public zero-argument method named '_CustomerView_fetch' found, performing generic datasource operation [java] === 2014-01-30 13:20:09,857 [l0-4] INFO SQLDataSource - [builtinApplication.CustomerView_fetch] Performing fetch operation with [java] criteria: {CustomerFName:"alex"} values: {CustomerFName:"alex"} [java] === 2014-01-30 13:20:09,857 [l0-4] INFO SQLDataSource - [builtinApplication.CustomerView_fetch] derived query: SELECT $defaultSelectClause FROM $defaultTableClause WHERE $defaultWhereClause ORDER BY $defaultOrderClause
Comment