Can't ListGrid.FetchData() again without modification except Criteria DROPONCHANGE
I uncessyfull try to fetchData() one more time without modification on the ListGrid.
The internal cache isn't modified and call fetchData() once again, don't call Fetch to server.
I try to change the default CriteriaPolicy from DROPONSHORTENING to DROPONCHANGE, but no more effect.
Servlet :
I think, the CriteriaPolicy.DROPONCHANGE doesn't work, on y don't know how to use.
So, why not add a new method or agument to force a new fetch on same DataSource unchanged ?
I uncessyfull try to fetchData() one more time without modification on the ListGrid.
The internal cache isn't modified and call fetchData() once again, don't call Fetch to server.
I try to change the default CriteriaPolicy from DROPONSHORTENING to DROPONCHANGE, but no more effect.
com.smartgwt.client.types.CriteriaPolicy.DROPONCHANGE
Cache is dropped whenever criteria changes.
Cache is dropped whenever criteria changes.
Code:
public class ModuleAccueil implements EntryPoint { ListGridField listGridFieldId = new ListGridField("id","Id"); listGridFieldId.setWidth("50px"); listGridFieldId.setHidden(true); ListGridField listGridFieldCentral = new ListGridField("zone","Zone"); listGridFieldCentral.setWidth("30px"); final ListGrid listGrid = new ListGrid(); listGrid.setHeaderSpans( new HeaderSpan("MyGrid", new String[]{"id", "zone"})); listGrid.setHeaderHeight(40); listGrid.setWidth(200); listGrid.setHeight(224); listGrid.setCanHover(true); listGrid.setCanAcceptDrop(true); listGrid.setCanAcceptDroppedRecords(true); listGrid.setCanDrag(true); listGrid.setCanDragRecordsOut(true); listGrid.setCanDrop(true); listGrid.setDragType("dndOtStock"); listGrid.setDropTypes("dndOtErreur","dndOtAffecte","dndOtStock"); listGrid.setDragDataAction(DragDataAction.MOVE); final RestDataSource dataSource = new RestDataSource(); dataSource.setDataFormat(DSDataFormat.XML); dataSource.setCriteriaPolicy(CriteriaPolicy.DROPONCHANGE); // dataSource.setCriteriaPolicy(CriteriaPolicy.DROPONSHORTENING); Map<String,String> defParams = new HashMap<String, String>(); defParams.put("mode", "myMode"); dataSource.setDefaultParams(defParams); OperationBinding fetch = new OperationBinding(); fetch.setOperationType(DSOperationType.FETCH); fetch.setDataProtocol(DSProtocol.POSTMESSAGE); dataSource.setOperationBindings(fetch); dataSource.setFetchDataURL(GWT.getModuleBaseURL()+"datasource"); DataSourceIntegerField idDs = new DataSourceIntegerField("id","Id"); idDs.setPrimaryKey(true); DataSourceTextField centralDs = new DataSourceTextField("zone","Zone"); dataSource.setFields(idDs,centralDs); dataSource.setCriteriaPolicy(CriteriaPolicy.DROPONCHANGE); dataSource.setCriteriaPolicy(CriteriaPolicy.DROPONSHORTENING); listGrid.setSortField(1); listGrid.setSortDirection(SortDirection.ASCENDING); listGrid.setDataSource(dataSource); listGrid.setAutoFetchData(true); Button button = new Button("Reload DataSource"); button.addClickHandler(new ClickHandler() { // @Override public void onClick(ClickEvent event) { System.out.println("onClick"); Criteria criteria = new Criteria(); criteria.addCriteria("criteriaField", "criteriaValue"); listGrid.fetchData(criteria); } }); VStack vsStack = new VStack(); vsStack.setMembers(listGrid,button); RootPanel.get().add(vsStack);
Code:
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { System.out.println("doPost"); StringBuilder sb = new StringBuilder(); sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); sb.append("<response>"); sb.append(" <status>0</status>"); sb.append(" <startRow>0</startRow>"); sb.append(" <endRow>5</endRow>"); sb.append(" <totalRows>5</totalRows>"); sb.append(" <data>"); sb.append(" <record><empty/><id>999999</id><zone>987</zone><fieldNotDisplay>NotSee</fieldNotDisplay></record>"); sb.append(" <record><empty/><id>710509</id><zone>KA1</zone><fieldNotDisplay>NotSee</fieldNotDisplay></record>"); sb.append(" <record><empty/><id>710510</id><zone>KA2</zone><fieldNotDisplay>NotSee</fieldNotDisplay></record>"); sb.append(" <record><empty/><id>710511</id><zone>KA3</zone><fieldNotDisplay>NotSee</fieldNotDisplay></record>"); sb.append(" <record><empty/><id>123456</id><zone>012</zone><fieldNotDisplay>NotSee</fieldNotDisplay></record>"); sb.append(" </data>"); sb.append("</response>"); response.getWriter().write(sb.toString()); }
So, why not add a new method or agument to force a new fetch on same DataSource unchanged ?
Comment