Hi Isomorphic,
While evaluation CubeGrid on SmartGWT 6.0, we have hit another issue.
We are unable to fetch data in paged fashion for CubeGrid.
We are trying to fetch data in Paged fashion from CubeGrid but setting cubeGrid.setDataFetchMode(FetchMode.Paged) does not help. The same settings work fine for ListGrid.
We want to use sqlLimit as Paging strategy and even after specifying it in the ds.xml the final query does not have Limit and offset appended.
The only thing which works is setting the startRow and endRow in dsRequest explicity on server side, but this means client has to be kept in sync for requesting further pages passing correct start and end rows.
We generate cube with 5 facets, and then fetch the values for the grid combinations post that.
The sample code looks something like: (borrowed from my prev. post at: http://forums.smartclient.com/forum/...ng-as-expected)
It is the fetch in the createCube() method that we would like to page.
Our current code has changed a bit, but the underlying mechanism remains almost same.
Is there a way to force fetching of the data for the cube in paged fashion?
I am also assuming that once this works fine, the export of this data should also not be a problem? (We are facing problem when exporting data from client currently, getting STATUS_MAX_POST_SIZE_EXCEEDED using the showcase code: http://forums.smartclient.com/forum/..._size_exceeded)
Thanks!
While evaluation CubeGrid on SmartGWT 6.0, we have hit another issue.
We are unable to fetch data in paged fashion for CubeGrid.
We are trying to fetch data in Paged fashion from CubeGrid but setting cubeGrid.setDataFetchMode(FetchMode.Paged) does not help. The same settings work fine for ListGrid.
We want to use sqlLimit as Paging strategy and even after specifying it in the ds.xml the final query does not have Limit and offset appended.
The only thing which works is setting the startRow and endRow in dsRequest explicity on server side, but this means client has to be kept in sync for requesting further pages passing correct start and end rows.
We generate cube with 5 facets, and then fetch the values for the grid combinations post that.
The sample code looks something like: (borrowed from my prev. post at: http://forums.smartclient.com/forum/...ng-as-expected)
It is the fetch in the createCube() method that we would like to page.
Our current code has changed a bit, but the underlying mechanism remains almost same.
Code:
package com.pankaj.gwt.example.client.cube; import com.google.gwt.core.client.EntryPoint; import com.smartgwt.client.data.DSCallback; import com.smartgwt.client.data.DSRequest; import com.smartgwt.client.data.DSResponse; import com.smartgwt.client.data.DataSource; import com.smartgwt.client.types.DSOperationType; import com.smartgwt.client.types.FetchMode; import com.smartgwt.client.widgets.cube.CubeGrid; import com.smartgwt.client.widgets.cube.Facet; import com.smartgwt.client.widgets.cube.FacetValue; import com.smartgwt.client.widgets.layout.VLayout; import java.util.ArrayList; import java.util.List; public class AdvancedCubeGrid implements EntryPoint { private String f1Values, f2Values, f3Values, f4Values, f5Values; final String F1 = "F1"; final String F2 = "F2"; final String F3 = "F3"; final String F4 = "F4"; final String F5 = "TITLE"; final String ALL = "ALL"; private CubeGrid cube; private VLayout mainLayout; @Override public void onModuleLoad() { getCubeGrid(); mainLayout = new VLayout(); mainLayout.setWidth100(); mainLayout.setHeight100(); mainLayout.setMembersMargin(8); mainLayout.setLayoutMargin(10); mainLayout.draw(); } private void getCubeGrid() { getCubeFacets(); } private void getCubeFacets() { final DSRequest request = new DSRequest(); request.setOperationType(DSOperationType.FETCH); request.setOperationId("fetchf1"); request.setShowPrompt(true); request.setWillHandleError(true); final DataSource dataSource = DataSource.get("cubeData"); dataSource.fetchData(null, new DSCallback() { @Override public void execute(DSResponse dsResponse, Object data, DSRequest dsRequestOld) { f1Values = CubeUtil.getStringFromData(dsResponse.getDataAsRecordList(), F1); request.setOperationId("fetchf2"); dataSource.fetchData(null, new DSCallback() { @Override public void execute(DSResponse dsResponse, Object data, DSRequest dsRequestOld) { f2Values = CubeUtil.getStringFromData(dsResponse.getDataAsRecordList(), F2); request.setOperationId("fetchf3"); dataSource.fetchData(null, new DSCallback() { @Override public void execute(DSResponse dsResponse, Object data, DSRequest dsRequestOld) { f3Values = CubeUtil.getStringFromData(dsResponse.getDataAsRecordList(), F3); request.setOperationId("fetchf4"); dataSource.fetchData(null, new DSCallback() { @Override public void execute(DSResponse dsResponse, Object data, DSRequest dsRequestOld) { f4Values = CubeUtil.getStringFromData(dsResponse.getDataAsRecordList(), F4); request.setOperationId("fetchf5"); dataSource.fetchData(null, new DSCallback() { @Override public void execute(DSResponse dsResponse, Object data, DSRequest dsRequest) { f5Values = CubeUtil.getStringFromData(dsResponse.getDataAsRecordList(), F5); createCube(); } }, request); } }, request); } }, request); } }, request); } }, request); } private void createCube() { cube = new CubeGrid(); cube.setWidth100(); cube.setHeight100(); cube.setDataFetchMode(FetchMode.LOCAL); cube.setHideEmptyFacetValues(true); List<Facet> facetList = new ArrayList<>(); facetList.add(getFacet(F1, "Origin", f1Values, true)); facetList.add(getFacet(F2, "Destination", f2Values, true)); facetList.add(getFacet(F3, "Quarter", f3Values, true)); facetList.add(getFacet(F4, "Month", f4Values, true)); facetList.add(getFacet(F5, "Values", f5Values, false)); cube.setAutoFetchData(true); cube.setFacets(facetList.toArray(new Facet[facetList.size()])); cube.setValueProperty("VAL"); cube.setRowFacets(F1, F2); cube.setColumnFacets(F3, F4, F5); DataSource dataSource = DataSource.get("cubeData"); cube.setDataSource(dataSource); [B]cube.setFetchOperation("fetchCubeData");[/B] mainLayout.addMember(cube); } private Facet getFacet(String facetName, String facetTitle, String facetValues, boolean isTree) { Facet facet = new Facet(); facet.setId(facetName); facet.setTitle(facetTitle); facet.setIsTree(isTree); facet.setCollapsed(false); facet.setValues(getFacetValues(facetValues, !isTree)); return facet; } private FacetValue[] getFacetValues(String facetValuesString, boolean isFixedFacet) { List<FacetValue> facetValues = new ArrayList<>(); if (!isFixedFacet) { facetValues.add(new FacetValue("sum", ALL)); } String[] facetValuesArray = facetValuesString.split(","); FacetValue facetValue; for (String facetString : facetValuesArray) { if (!isFixedFacet) { facetValue = new FacetValue(facetString, facetString, "sum"); } else { facetValue = new FacetValue(facetString, facetString); } facetValues.add(facetValue); } for (FacetValue facet : facetValues) { facet.setWidth(100); } return facetValues.toArray(new FacetValue[facetValues.size()]); } }
Code:
package com.pankaj.gwt.example.client.cube; import com.smartgwt.client.data.RecordList; public class CubeUtil { public static String getStringFromData(RecordList recordList, String propertyName) { StringBuilder stringBuilder= new StringBuilder(); for(int i = 0 ; i < recordList.getLength(); i ++) { stringBuilder.append(recordList.get(i).getAttribute(propertyName)); if (i < recordList.getLength() - 1) { stringBuilder.append(","); } } return stringBuilder.toString(); } }
Code:
<DataSource ID="cubeData" tableName="CUBE_DATA" serverType="sql" dbName="Oracle"> <fields> <field name="F1" type="text"/> <field name="F2" type="text"/> <field name="F3" type="text"/> <field name="F4" type="text"/> <field name="TITLE" type="text"/> <field name="VAL" type="integer"/> </fields> <operationBindings> <operationBinding operationType="fetch" operationId="fetchCubeData"></operationBinding> <operationBinding operationType="fetch" operationId="fetchf1"> <selectClause> DISTINCT F1 </selectClause> </operationBinding> <operationBinding operationType="fetch" operationId="fetchf2"> <selectClause> DISTINCT F2 </selectClause> </operationBinding> <operationBinding operationType="fetch" operationId="fetchf3"> <customSQL> SELECT DISTINCT F3 FROM CUBE_DATA ORDER BY CASE F3 WHEN 'Q1' THEN 1 WHEN 'Q2' THEN 2 WHEN 'Q3' THEN 3 WHEN 'Q4' THEN 4 END </customSQL> </operationBinding> <operationBinding operationType="fetch" operationId="fetchf4"> <customSQL> SELECT DISTINCT F4 FROM CUBE_DATA ORDER BY CASE F4 WHEN 'JAN' THEN 1 WHEN 'FEB' THEN 2 WHEN 'MAR' THEN 3 WHEN 'APR' THEN 4 WHEN 'MAY' THEN 5 WHEN 'JUN' THEN 6 WHEN 'JUL' THEN 7 WHEN 'AUG' THEN 8 WHEN 'SEP' THEN 9 WHEN 'OCT' THEN 10 WHEN 'NOV' THEN 11 WHEN 'DEC' THEN 12 END </customSQL> </operationBinding> <operationBinding operationType="fetch" operationId="fetchf5"> <selectClause> DISTINCT TITLE </selectClause> </operationBinding> </operationBindings> </DataSource>
I am also assuming that once this works fine, the export of this data should also not be a problem? (We are facing problem when exporting data from client currently, getting STATUS_MAX_POST_SIZE_EXCEEDED using the showcase code: http://forums.smartclient.com/forum/..._size_exceeded)
Thanks!
Comment