Servoy / aggridcomponents

Advanced table components based on ag-Grid
MIT License
5 stars 10 forks source link

Error: TypeError: Cannot read property "0" from undefined #4

Open ErosN opened 6 years ago

ErosN commented 6 years ago

Getting the following error in servoy-admin when grouping a column. Note that this works in developer without any issues, but when deployed it gives this error and it doesn't group:

org.mozilla.javascript.EcmaError: TypeError: Cannot read property "0" from undefined at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3772) at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3756) at org.mozilla.javascript.ScriptRuntime.typeError(ScriptRuntime.java:3777) at org.mozilla.javascript.ScriptRuntime.typeError2(ScriptRuntime.java:3793) at org.mozilla.javascript.ScriptRuntime.undefReadError(ScriptRuntime.java:3804) at org.mozilla.javascript.ScriptRuntime.getObjectElem(ScriptRuntime.java:1456) at org.mozilla.javascript.gen.C__tomcat_webapps_WebClient_aggrid_groupingtable_groupingtable_server_js_9._c_anonymous_1(Unknown Source) at org.mozilla.javascript.gen.C__tomcat_webapps_WebClient_aggrid_groupingtable_groupingtable_server_js_9.call(Unknown Source) at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:406) at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3204) at org.mozilla.javascript.gen.C__tomcat_webapps_WebClient_aggrid_groupingtable_groupingtable_server_js_9.call(Unknown Source) at com.servoy.j2db.server.ngclient.component.RuntimeWebComponent.executeScopeFunction(RuntimeWebComponent.java:150) at com.servoy.j2db.server.ngclient.NGFormServiceHandler.executeMethod(NGFormServiceHandler.java:411) at org.sablo.websocket.WebsocketEndpoint$5.run(WebsocketEndpoint.java:333) at org.sablo.eventthread.Event$1.run(Event.java:100) at org.sablo.websocket.CurrentWindow.runForWindow(CurrentWindow.java:77) at org.sablo.eventthread.Event.execute(Event.java:90) at org.sablo.eventthread.EventDispatcher.dispatch(EventDispatcher.java:125) at org.sablo.eventthread.EventDispatcher.run(EventDispatcher.java:89) at com.servoy.j2db.server.ngclient.eventthread.NGEventDispatcher.run(NGEventDispatcher.java:55) at java.lang.Thread.run(Unknown Source)

The Grid is located in a responsive form.

paronne commented 6 years ago

Hi, if i understand correctly you are using a grouping grid with no grouped columns at design time, as soon you group on a column (any column ?) you get the error above and the rows are not grouped (does still shows the ungrouped rows ?) Do you see any error in the Browser's console as well ?

Please note that the grouping grid requires one, and one only, primary key on the foundset is bound to. Also the column you are grouping on must be a column of you dataSource, cannot be an aggregation or a calculation.

ErosN commented 6 years ago

Hi Paolo,

The grid is bound to a in memory datasource, which previously did not have a pk. I added changed one column to a PK, but I am still getting the same issues.

To answer your questions, it does still show the ungrouped rows, and the error in the browsers console is the same as the error in servoy-admin.

image

paronne commented 6 years ago

Hi, the error is server side, the log you posted in your first message doesn't say much unfortunately because the javascript code is compiled. I was not able to replicate the issue in a sample. You can add this property to you servoy.properties file (for testing reason only), it may provide a more readable stack of the error.

servoy.disableScriptCompile=true

Regards, Paolo

ErosN commented 6 years ago

Hi Paolo,

I am now seeing two different errors, one is coming from a grid that is bound to an in memory table. Here is the error:

Wrapped com.servoy.j2db.dataprocessing.DataException: Unknown errorCode 100
column of LOB or ARRAY type cannot be used in operation in statement [select min("TEMP_96-4C87-AED2-12B45B2B4D41"."_sv_rowid") from "TEMP_2_5E039F1D-AE96-4C87-AED2-12B45B2B4D41" "TEMP_96-4C87-AED2-12B45B2B4D41" where "TEMP_96-4C87-AED2-12B45B2B4D41".status = ? group by  "TEMP_96-4C87-AED2-12B45B2B4D41".invoice_number order by "TEMP_96-4C87-AED2-12B45B2B4D41".invoice_number asc]

The other error is coming from a different grid who's foundset is a ProgressDB table. This table has multiple PKs:

Grouping is not supported on foundset having multiple primary keys. The component's foundset must have one single primary key (#93)

paronne commented 6 years ago

Hi,

the first type of error is related to the in-mem datasource itself; it may happen for example when the executed query does an "ORDER BY" on a column of type TEXT which doesn't have a length defined (in the design of the in-mem table you can set the length of the column). The query indeed contains an ORDER BY; is the invoice number of type TEXT ? you may be able to reproduce the same error just trying to sort on the column invoice_number. To resolve this error just set a length in the column properties.

The second error is indeed notifying you that grouping is not supported on foundset of multiple primary keys. To use the grouping functionality of the grid component the foundset must have a single pk.

Regards, Paolo

ErosN commented 6 years ago

Hi Paolo,

Thank you for the answers. It seems to work now.

ErosN commented 6 years ago

Hi Paolo,

This is still an issue. It works on developer but not once its deployed.

Servoy Admin error: image

Console error: image

paronne commented 6 years ago

Hi, since the error is server side, the log you posted in your first message doesn't say much unfortunately because the javascript code is compiled. You can disable the compiling of the javascript adding this property to you servoy.properties file (for testing reason only), it may provide a more readable stack of the error.

servoy.disableScriptCompile=true

Regards, Paolo

ErosN commented 6 years ago

Hi Paolo,

We added that property to the Servoy.properties file, and redeployed the solution, the end result is the same. We get the same exact errors.

Eros

ErosN commented 6 years ago

Hi Paolo,

Do we have an update on this?

paronne commented 6 years ago

Hi Eros,

unfortunately i have no updates yet on this matter. hard to debug this particoular issue without being able to reproduce it. Is still the case that is reproducible only in production ? Do you always get this issue or it depends on the grouped columns and it's data ?

Regards, Paolo

ErosN commented 6 years ago

Hi Paolo,

I can never get this to work in production, not even once. It works only when running from Servoy Developer.

I can show you the issue through GoToMeeting.

Eros

paronne commented 6 years ago

Hi Eros,

no need for the GoToMeeting session. Since in your case is always reproducible, Can you prepare a small sample solution where the issue is reproducible and attach it to the issue ? Would really appreciate that since it will help the debugging.

Thank you, Paolo

paronne commented 6 years ago

aggrid.zip

Hi Eros,

Have you managed to replicate the issue in a sample solution ?

I have attached here a patched version of the ag-grid component, where i have enabled some logging into the server-side scripting that is failing. Hopefully will help to better understand what is going on. E.g. START SERVER SIDE ------------------------------------------ .... ... other messages in between END SERVER SIDE QUERY -------------------------------------- at...

You can use this component in your project; remove the existing ag-grid you currently use and import the attached zip package into the Web Packages.

Note: to enable the logging on server side you must set the Debug level to INFO: log4j.logger.com.servoy.j2db.util.Debug=INFO

Can you do some testing and provide me the servoy_log.txt ? Thank you.

Regards, Paolo