Grid displays nothing, eventhough displays of rows

Hey folks,

i got a weird problem, i am not sure what could be the problem,
the grid is displaying but shows no data in it, shows empty rows though i e., if there are 7 rows, then displays 7 rows, but does not seem to display data.
my jsp page :

<script tags 
dhtmlx.js
dhtmlxdataprocessor.js
connector.js
style.css
dhtmlx.css
jquery-1.8.0.js
</scirpt>
<body>
<input type="button" value="Show Grid" onClick="clickOnButton(this)" />
<div id="gridbox" width="1024px" height="500px" style="background-color:white"></div>
<script>


function clickOnButton(bt)
{

mygrid = new dhtmlxGridObject('gridbox');
mygrid.setInitWidths("90,*");
mygrid.setSizes();
mygrid.enableSmartRendering(true);
mygrid.enableMultiselecdt(true);
mygrid.init();
mygrid.loadXML("LoadGridData.data?question="questionID"+"&userId="+userId);
var dp = new dataProcessor("LoadGridData.data?question="questionID"+"&userId="+userId);
dp.init(mygrid);
}
</script>
LoadGridData.java servlet which extends ThreadSafeConnectorServlet
configure(req, res)
{
LoadGridData.java

GridConnector gridConnect = new GridConnector(manager.getSqlConnection(), DBType.PostgreSQL);
grid.servlet(req, res);
GridConfiguration gridConfig = new GridConfiguration();
GridColumn gridCol;

grid = new GridColumn()
gridCol.setHeader("Name of User");
gridCol.setType("ed");
GridCol.setId("name");
gridConfig.addColumn(gridCol);

--A loop which does the same adding of grid columns into GridConfig--
gridConnect.dynamic_loading(true);
gridConnect.dynamic_loading(2);
gridConnect.set_encoding("UTF-8");
gridConnect.setConfiguration(gridConfig);
if(gridConnect.is_select_mode())
   gridConnect.render_sql("select user.name from user");
else
  gridConnect.render_table("user", "name", "name");
}

the query is much bigger than the given query above.
i did enable the log and check, seems like each query has been successfully executed loaded.
there is some configuration i think i have missed that is making the actuall data no showUp.
I did check quite a lot of reading on the forum, didnt find much on this issue.
Please could you guys help figure this out.

The code must looks as

if(gridConnect.is_select_mode()) gridConnect.render_sql("select user.name, user.id from user","id","name"); else gridConnect.render_table("user", "id", "name");

You need to specify second and third parameters in render_sql command with id and fields names

hi,
no that was just an example.
the actual statement is :

if(gridConnect.is_select_mode())
{
gridConnect.render_sql("Select table1.name, table2.id, table2.value1, table2.value2, table2.value3 from table1, table2 where table1.id=table2.id and table1.value6='new and table1.value7=false"," table2.id, table1.name, table2.id, table2.value1, table2.value2, table2.value3");
} 
else
{ 
gridConnect.render_table("table2", "table2.id", "table2.id,  table2.value1, table2.value2, table2.value3");

also i just found out that the xml that is coming in to the jsp page is coming with cell values as being empty, this i found out by just entering the complete URL of servlet with the get parameters, and the browser just gave an XML with tag being just empty. WHAT COULD THE PROBLEM BE?
the postgres data is coming from a different server, does it affect in anyway?

hi,
no that was just an example.
the actual statement is :

Select all if(gridConnect.is_select_mode()) { gridConnect.render_sql("Select table1.name, table2.id, table2.value1, table2.value2, table2.value3 from table1, table2 where table1.id=table2.id and table1.value6='new and table1.value7=false"," table2.id", "table1.name, table2.id, table2.value1, table2.value2, table2.value3"); -- the id is from table2 } else { gridConnect.render_table("table2", "table2.id", "table2.id, table2.value1, table2.value2, table2.value3");

also i just found out that the xml that is coming in to the jsp page is coming with cell values as being empty, this i found out by just entering the complete URL of servlet with the get parameters, and the browser just gave an XML with tag being just empty. WHAT COULD THE PROBLEM BE?
the postgres data is coming from a different server, does it affect in anyway?

It still contains invalid parameters

gridConnect.render_sql("Select table1.name as name1, table2.id as id2, table2.value1 as value21, table2.value2 as value22, table2.value3 as value32 from table1, table2 where table1.id=table2.id and table1.value6='new and table1.value7=false","table2.id(id2)", "table1.name(name1),...");
  • use “as” to give unique alias for each fields
  • in list field write the full name and after that alias in

hi, thank you very much Stanislav,
i got it to work, data is displaying now, though edit is not happening.
how do we enable the edit option now?

If you mean client side edit - it depends on column types ( grid.setColTypes ) “ed” type will produce inline editor on dbl-click.

If you have problems on server side during saving - please enable logging and provide log content for the problematic operation.

HI Stainislav,

edits is happening weirdly …

if(gridConnect.is_select_mode()) gridConnect.render_sql("select table1.id as id, table1.name as tname, table2.value1 as t1, table2.value2 as t2, table2.value3 as t3 from table1, table2 where table1.id=table2.id and table1.status='new' ", "table1.id(id)"," table1.id(id), table1.name(tname), table2.value1(t1),table2.value2(t2),table2.value1(t3)"); else // for editing the table gridConnect.render_table("table2","table2.id", "table2.value1(t1),table2.value2(t2),table2.value1(t3)");

now the table is displaying …

------------------------------------------------
id | name | value1 | value2 | value3
------------------------------------------------
 2    ray       2        3           4

now when i edit the value1 field to say ‘234’
the update statement is getting formed as(log information)

update set table2 set id=‘2’, value1=‘ray’, value2=‘234’, value3=‘3’ where id=‘2’

how do i change this? the update table should not take the name field value at all…

Client side code sends data for all columns and server side code will try to map them to fields from table. First column - first field, second column - second field, etc.

You need to have order of columns the same as in render-for-loading instruction

 gridConnect.render_table("table2", "id", "id, name, value1, value2, value3");

if you need not some field ( as name ) , you can use custom update query, or use the above one, but add beforeProcessing behavior, from which remove name column from update

class CustomBehavior extends ConnectorBehavior{ @Override public void beforeUpdate(DataAction data) { data.remove_field("name"); } } component.event.attach(new CustomBehavior());

HI Stainslav,

i have updated my code,

gridConnect.setConfiguration(gridConfig);
gridConnect.event.attach(new GridUpdateBehaviout());
 gridConnect.servlet(req,res);
if(gridConnect.is_select_mode())
gridConnect.render_sql("select table1.id as id, table1.name as tname, table2.value1 as t1, table2.value2 as t2, table2.value3 as t3 from table1, table2 where table1.id=table2.id and table1.status='new' ", "table1.id(id)"," table1.id(id), table1.name(tname), table2.value1(t1),table2.value2(t2),table2.value3(t3)");
else // for editing the table
gridConnect.render_table("table2","id", "id, name, value1,value2,value3");

this this is my GridUpdateBehaviour()


public class GridUpdateBehaviour extends ConnectorBehavior {

@override
public void beforeUpdate(DataAction action) {
   System.out.println("removed the field :"+action.get_value("name");
  action.remove_field("name");
 }

}

the name field is printing the value as ‘ray’ …

after i edit a row, i get an IndexOutOfBoundsException in DataAction class.


removed the field :ray
Sep 6, 2012 8:23:15 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [LoadGridData] in context with path [/AxxonetPortal] threw exception
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
	at java.util.ArrayList.RangeCheck(Unknown Source)
	at java.util.ArrayList.get(Unknown Source)
	at com.dhtmlx.connector.DataAction.sync_config(DataAction.java:98)
	at com.dhtmlx.connector.DataProcessor.check_exts(DataProcessor.java:270)
	at com.dhtmlx.connector.DataProcessor.inner_process(DataProcessor.java:222)
	at com.dhtmlx.connector.DataProcessor.process(DataProcessor.java:127)
	at com.dhtmlx.connector.BaseConnector.render(BaseConnector.java:411)
	at com.dhtmlx.connector.BaseConnector.render_table(BaseConnector.java:242)
	at com.dhtmlx.connector.BaseConnector.render_table(BaseConnector.java:210)
	at com.axxportal.servlets.GridData.configure(GridData.java:132)
	at com.dhtmlx.connector.ThreadSafeConnectorServlet.doGet(ThreadSafeConnectorServlet.java:19)
	at com.dhtmlx.connector.ThreadSafeConnectorServlet.doPost(ThreadSafeConnectorServlet.java:29)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:225)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:999)
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:565)
	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:309)
	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)

HI Stanislav,

After further investigating this issue,
drilled down to the DataAction clas where found the following code,

config.remove_field(addf.get(i))

i think config.remove should use the delf array to remove/delete the list of fields
instead it is using the addf (add field) array to get the delete list.

Is this the intended behaviour ?
Thank you.

[code]
class DataAction.java
public void sync_config(DataConfig config) throws ConnectorConfigException{
for (int i=0; i<addf.size(); i++)
config.add_field(addf.get(i));
for (int i=0; i<delf.size(); i++)
config.remove_field(addf.get(i)); //Is this intended ?
}

}[/code]

You are right, this line of code is source of the problem.
Fixed version of connector.jar is attached.
connector_latest.zip (277 KB)

Hi Stainislav,

thank you for the prompt response.
seems like the jar file you have given is complied with java 7,
when i try to compile in eclipse throws an error saying "UnsupportedClassVersionError : com/dhtmlx/connector/ThreadSafeConnectorServlet : Unsupported major.minor version 51.0 " …

Hi,

could you please recompile with 1.6 and provide.
most online host providers will not give 1.7 version as yet…

Java6 version is attached
connector6.zip (277 KB)

HI Stainislav,

Amazing! … thank you that worked!! :smiley: :smiley:
Thank you very much for the committed responses. Your awesome!!