Dude, if u=you set cansort = false, how can you expect to sort something :)? In order to force server sorting only, always invalidate the cache.
Originally posted by ynaik
... private GenericDataServiceAsync<M> service; ... public SmartGWTDataSource(HasSmartGWTResources<M> bridge, GenericDataServiceAsync<M> serviceInstance) { super(); GWT.log("Beginning DS init", null); setDataProtocol(DSProtocol.CLIENTCUSTOM); setDataFormat(DSDataFormat.CUSTOM); setClientOnly(false); this.resource = bridge; service = serviceInstance; GWT.log("Adding fields", null); for (DataSourceField field : bridge.getDataSourceFields()) { GWT.log("adding field " + field.getName(), null); addField(field); } GWT.log("SmartGWTDataSource() initialized.", null); }
.... Canvas canvas = new Canvas(); SmartGWTDataSource<Database, DatabaseBridge, DatabaseService> theDatasource = new SmartGWTDataSource<Database, DatabaseBridge, DatabaseService>( DatabaseBridge.Util.getInstance(), DatabaseServiceAsync.Util.getInstance()); ....
public interface DatabaseServiceAsync extends GenericDataServiceAsync<Database> { public static class Util { private static DatabaseServiceAsync instance; public static DatabaseServiceAsync getInstance() { if (instance == null) { instance = GWT.create(DatabaseService.class); } return instance; } } }
response.setData (request.getData ());
JavaScriptObject jsObj = request.getData(); String[] properties = JSOHelper.getProperties(jsObj); if (properties != null && properties.length > 0) { ...
Criteria crit = request.getCriteria(); Map critMap = crit.getValues(); for (Object key : critMap.keySet()) { Object val = critMap.get(key); System.out.println("Criteria key " + key + " with value " + val); }
// Override date field DateItem openedItem = new DateItem(); openedItem.setName("accountOpened"); openedItem.setTitle("Account Opened"); openedItem.setUseTextField(true); openedItem.setDisplayFormat(DateDisplayFormat.TOEUROPEANSHORTDATE); openedItem.setInputFormat("DMY"); boundForm.setFields(openedItem);
dateField = new DataSourceDateField("accountOpened", "Account Opened"); dateField.setRequired(false); dateField.setCanSave(false); addField(dateField);
public class MMCClient implements EntryPoint { private ServiceNodesTreeGrid serviceNodesCanvas; public void onModuleLoad() { VLayout containerLayout = new VLayout(); HLayout topPane = new HLayout(); serviceNodesCanvas = new ServiceNodesTreeGrid(); topPane.addMember(serviceNodesCanvas); containerLayout.addMember(topPane); RootPanel.get("mmcclient").add(containerLayout); } public class ServiceNodesServiceImpl extends RemoteServiceServlet implements ServiceNodesService, Serializable, IsSerializable { static List<ServiceNodeRecord> staticList = new ArrayList<ServiceNodeRecord>(); static ServiceNodeRecord record = null; // load static data for testing static { record = new ServiceNodeRecord(); record.setConnectsTo("0"); record.setNodeId("1"); record.setInstitutionId("220"); record.setServiceName("hub-dev"); record.setNodeType("HUB"); staticList.add(record); record = new ServiceNodeRecord(); record.setConnectsTo("1"); record.setNodeId("6"); record.setInstitutionId("220"); record.setServiceName("mmc"); record.setNodeType("MMC"); } public List<ServiceNodeRecord> fetch() { return staticList; } } public class ServiceNodeDataSource extends GwtRpcDataSource { public ServiceNodeDataSource () { DataSourceField field; field = new DataSourceIntegerField ("nodeId", "nodeId"); // field.setPrimaryKey (true); field.setRequired (true); addField (field); field = new DataSourceTextField ("institutionId", "Id"); field.setRequired (true); addField (field); field = new DataSourceTextField ("connectsTo", "Connects"); // field.setForeignKey("connectsTo"); field.setRequired (true); addField (field); field = new DataSourceTextField ("serviceName", "Service"); field.setRequired (true); addField (field); field = new DataSourceTextField ("nodeType", "Type"); field.setRequired (true); addField (field); @Override protected void executeFetch (final String requestId, final DSRequest request, final DSResponse response) { SC.logWarn ("in executeFetch"); ServiceNodesServiceAsync service = GWT.create (ServiceNodesService.class); service.fetch (new AsyncCallback<List<ServiceNodeRecord>> () { public void onFailure (Throwable caught) { response.setStatus (RPCResponse.STATUS_FAILURE); processResponse (requestId, response); } public void onSuccess (List<ServiceNodeRecord> result) { TreeNode[] list = new TreeNode[result.size ()]; for (int i = 0; i < list.length; i++) { TreeNode record = new TreeNode(); copyValues (result.get (i), record); list[i] = record; } response.setData (list); processResponse (requestId, response); } }); } // fetch from, to private static void copyValues (ServiceNodeRecord from, TreeNode to) { to.setParentID(from.getNodeId()); System.out.println("setParentID = " + from.getNodeId()); to.setAttribute("nodeId", from.getNodeId()); to.setAttribute("connectsTo", from.getConnectsTo()); to.setAttribute("serviceName", from.getServiceName ()); to.setAttribute("institutionId", from.getInstitutionId ()); to.setAttribute("nodeType", from.getNodeType()); } } public class ServiceNodesTreeGrid extends TreeGrid { public ServiceNodesTreeGrid() { TreeGridField institutionId = new TreeGridField("institutionId", "Node"); TreeGridField serviceNameField = new TreeGridField("serviceName", "Service"); TreeGridField nodeTypeField = new TreeGridField("nodeType", "Type"); setFields(institutionId, serviceNameField, nodeTypeField); ServiceNodeDataSource dataSource = new ServiceNodeDataSource(); setDataSource(dataSource); this.invalidateCache(); this.fetchData(); } } public class ServiceNodeRecord implements Serializable { private static final long serialVersionUID = 1L; private String nodeId; private String serviceName; private String institutionCode; private String nodeType; private String connectsTo; public String getNodeId() { return nodeId; } public void setNodeId(String nodeId) { this.nodeId = nodeId; } public String getConnectsTo() { return connectsTo; } public void setConnectsTo(String connectsTo) { this.connectsTo = connectsTo; } public String getNodeType() { return nodeType; } public void setNodeType(String nodeType) { this.nodeType = nodeType; } public String getServiceName() { return serviceName; } public void setServiceName(String serviceName) { this.serviceName = serviceName; } public String getInstitutionId() { return institutionId; } public void setInstitutionId(String institutionId) { this.institutionId = institutionId; } }
Comment