1.SmartClient Version: v10.1p_2016-02-02/LGPL Development Only (built 2016-02-02)
2.Chrominium 38.0.2125.101 (290379) (64-bit), FF 24.8.0
3.
4.JS stack trace:
5.Sample code:
Sample data:
Employment.xml
Department.xml
Hi,
In the above example If you try to group by "Employer" field then you got JS error as attached.
Grouping by "Employer Code" field works fine. Also, hiding "Employer Code" field first, and then grouping by "Employer" field works perfectly.
Characteristic here is that displayField attribuute of the foreign key field "employer" is set to other name in the same record "employer_code" (as suggested by docs for large data sets).
MichalG
2.Chrominium 38.0.2125.101 (290379) (64-bit), FF 24.8.0
3.
4.JS stack trace:
Code:
17:29:58.881:MUP2:WARN:Log:TypeError: Cannot read property 'groupingMode' of undefined Stack from error.stack: ListGrid.regroup(<no args: exited>) on [ListGrid ID:isc_ListGrid_0] @ ISC_Grids.js:2771:187 ListGrid.dataChanged(<no args: exited>) on [ListGrid ID:isc_ListGrid_0] @ ISC_Grids.js:1062:45 ListGrid.groupBy(<no args: exited>) on [ListGrid ID:isc_ListGrid_0] @ ISC_Grids.js:2855:70 ListGrid.setGroupSpecifiers(<no args: exited>) on [ListGrid ID:isc_ListGrid_0] @ ISC_Grids.js:2840:38 groupField(<no args: exited>) on [Menu ID:isc_ListGrid_0$314] @ ISC_Grids.js:925:99 click(<no args: exited>) @ ISC_Grids.js:2657:172 Menu.selectMenuItem(<no args: exited>) on [Menu ID:isc_ListGrid_0$314] @ ISC_Grids.js:3216:46 Menu.rowClick(<no args: exited>) on [Menu ID:isc_ListGrid_0$314] @ ISC_Grids.js:3202:286 eval(<no args: exited>) on [GridBody ID:isc_ListGrid_0$314_body] @ [no file]:4:115 GridRenderer._rowClick(<no args: exited>) on [GridBody ID:isc_ListGrid_0$314_body] @ ISC_Grids.js:689:183 [c]Class.invokeSuper(<no args: exited>) on [GridBody ID:isc_ListGrid_0$314_body] @ ISC_Core.js:270:93 [c]Class.Super(<no args: exited>) on [GridBody ID:isc_ListGrid_0$314_body] @ ISC_Core.js:262:170 GridBody._rowClick(<no args: exited>) on [GridBody ID:isc_ListGrid_0$314_body] @ ISC_Grids.js:756:76 GridRenderer.click(<no args: exited>) on [GridBody ID:isc_ListGrid_0$314_body] @ ISC_Grids.js:687:167 Canvas.handleClick(<no args: exited>) on [GridBody ID:isc_ListGrid_0$314_body] @ ISC_Core.js:2899:400 [c]EventHandler.bubbleEvent(<no args: exited>) on [Class EventHandler] @ ISC_Core.js:1625:89 [c]EventHandler.handleClick(<no args: exited>) on [Class EventHandler] @ ISC_Core.js:1485:50 EventHandler._handleMouseUp(<no args: exited>) on [Class EventHandler] @ ISC_Core.js:1470:11 [c]EventHandler.handleMouseUp(<no args: exited>) on [Class EventHandler] @ ISC_Core.js:1461:57 [c]EventHandler.dispatch(_1=>[c]EventHandler.handleMouseUp(), _2=>[object MouseEvent]) on [Class EventHandler] @ ISC_Core.js:1699:108 HTMLDocument.eval(event=>[object MouseEvent]) @ [no file]:3:123
Code:
package pl.com.tech4.client; import com.google.gwt.core.client.EntryPoint; import com.google.gwt.user.client.DOM; import com.smartgwt.client.data.DataSource; import com.smartgwt.client.data.DataSourceField; import com.smartgwt.client.data.OperationBinding; import com.smartgwt.client.data.fields.DataSourceTextField; import com.smartgwt.client.types.DSDataFormat; import com.smartgwt.client.types.DSOperationType; import com.smartgwt.client.types.DSProtocol; import com.smartgwt.client.util.SC; import com.smartgwt.client.widgets.grid.ListGrid; import com.smartgwt.client.widgets.grid.ListGridField; public class MainEntryPoint implements EntryPoint { public void onModuleLoad() { DOM.getElementById("loadingPicture").removeFromParent(); layout(); SC.showConsole(); } private void layout() { DataSource employmentDS = new DataSource(); employmentDS.setID("Employment"); OperationBinding fetchBinding = new OperationBinding(); fetchBinding.setOperationType(DSOperationType.FETCH); fetchBinding.setDataFormat(DSDataFormat.XML); fetchBinding.setDataProtocol(DSProtocol.POSTXML); employmentDS.setOperationBindings(fetchBinding); employmentDS.setDataURL("Employment.xml"); DataSourceField idField = new DataSourceField(); idField.setName("id"); idField.setPrimaryKey(true); idField.setHidden(true); DataSourceField employerField = new DataSourceField(); employerField.setName("employer"); employerField.setForeignKey("Department.id"); employerField.setValueXPath("employer/id"); ListGridField employerListGridField = new ListGridField("employer"); employerListGridField.setDisplayField("employer_code"); DataSourceTextField employer_codeField = new DataSourceTextField(); employer_codeField.setName("employer_code"); employer_codeField.setValueXPath("employer/code"); employmentDS.setFields(idField, employerField, employer_codeField); DataSource departmentDS = new DataSource(); departmentDS.setID("Department"); departmentDS.setOperationBindings(fetchBinding); departmentDS.setDataURL("Department.xml"); DataSourceField idDepField = new DataSourceField(); idDepField.setName("id"); idDepField.setPrimaryKey(true); idDepField.setHidden(true); DataSourceTextField codeField = new DataSourceTextField(); codeField.setName("code"); departmentDS.setFields(idDepField, codeField); ListGrid lg = new ListGrid(); lg.setWidth(300); lg.setCanEdit(true); lg.setAutoSaveEdits(false); ListGridField lgf = new ListGridField("employer"); lgf.setDisplayField("employer_code"); lg.setFields(lgf); lg.setDataSource(employmentDS); lg.setUseAllDataSourceFields(true); lg.fetchData(); lg.draw(); } }
Employment.xml
Code:
<response> <status>STATUS_SUCCESS</status> <startRow>0</startRow> <endRow>1</endRow> <totalRows>2</totalRows> <data> <Employment> <id>20</id> <employer> <id>3</id> <code>Microsoft</code> </employer> </Employment> <Employment> <id>21</id> <employer> <id>4</id> <code>Apple</code> </employer> </Employment> </data> </response>
Code:
<response> <status>STATUS_SUCCESS</status> <startRow>0</startRow> <endRow>4</endRow> <totalRows>5</totalRows> <data> <Department> <id>1</id> <code>Oracle</code> <parentId> <id>2</id> <code>Sun</code> </parentId> </Department> <Department> <id>2</id> <code>Sun</code> <parentId> <id>2</id> <code>Sun</code> </parentId> </Department> <Department> <id>3</id> <code>Microsoft</code> <parentId> <id>2</id> <code>Sun</code> </parentId> </Department> <Department> <id>4</id> <code>Apple</code> <parentId> <id>2</id> <code>Sun</code> </parentId> </Department> </data> </response>
In the above example If you try to group by "Employer" field then you got JS error as attached.
Grouping by "Employer Code" field works fine. Also, hiding "Employer Code" field first, and then grouping by "Employer" field works perfectly.
Characteristic here is that displayField attribuute of the foreign key field "employer" is set to other name in the same record "employer_code" (as suggested by docs for large data sets).
MichalG
Comment