RENDER_SQL Issue is driving me insane

I have a grid that loads contact data for the selected record, but when I try to use render_sql it fails.

my connector code is as follows:

	require_once("config.php");
	$res=mysql_connect($mysql_server,$mysql_user,$mysql_pass);
	mysql_select_db($mysql_db);

	require("dhtmlx/connector/grid_connector.php");
	$grid = new GridConnector($res);
	$config = new GridConfiguration();
 	$config->setHeader("ID,First Name,Last Name,Title,Office,Extn,Mobile,Email");
	$config->setColTypes("ro,ed,ed,ed,ed,ed,ed,ed");
	$grid->set_config($config);
	$grid->enable_log("temp.log",true);
	$grid->dynamic_loading(10);

if ($grid->is_select_mode()){//code for loading data
    $grid->render_sql("Select * from vendor_registration_contact WHERE VEND_REG_ID=".$SelectID, "VEND_CONT_ID","VEND_REG_ID, VEND_FNAME, VEND_LNAME,VEND_TITLE,VEND_PHONE,VEND_EXTN,VEND_MOBILE,VEND_EMAIL1");
    }else {//code for other operations - i.e. update/insert/delete
		$grid->render_table("vendor_registration_contact","VEND_CONT_ID","VEND_REG_ID, VEND_FNAME,VEND_LNAME,VEND_TITLE,VEND_PHONE,VEND_EXTN,VEND_MOBILE,VEND_EMAIL1");
	}

If I uses render_table, the grid loads just fine, but it fails with render sql.

I checked the XML returned and for render_table it is as follows:

  <?xml version="1.0" encoding="utf-8" ?> 
- <rows total_count="13">
- <head>
  <column type="ro" width="100">ID</column> 
  <column type="ed" width="100">First Name</column> 
  <column type="ed" width="100">Last Name</column> 
  <column type="ed" width="100">Title</column> 
  <column type="ed" width="100">Office</column> 
  <column type="ed" width="100">Extn</column> 
  <column type="ed" width="100">Mobile</column> 
  <column type="ed" width="100">Email</column> 
- <settings>
  <colwidth>px</colwidth> 
  </settings>
  </head>
- <row id="20">
- <cell>
- <![CDATA[ 10
  ]]> 
  </cell>
- <cell>
- <![CDATA[  #######
  ]]> 
  </cell>
- <cell>
- <![CDATA[ unknown
  ]]> 
  </cell>
- <cell>
- <![CDATA[ Business Development
  ]]> 
  </cell>
- <cell>
- <![CDATA[ 
  ]]> 
  </cell>
- <cell>
- <![CDATA[ 
  ]]> 
  </cell>
- <cell>
- <![CDATA[ 
  ]]> 
  </cell>
- <cell>
- <![CDATA[ 
  ]]> 
  </cell>
  </row>
  </rows>[/code]

and for render_sql it is as follows. The header is dropped:

[code]  <?xml version="1.0" encoding="utf-8" ?> 
- <rows total_count="1">
- <row id="28">
- <cell>
- <![CDATA[ 1
  ]]> 
  </cell>
- <cell>
- <![CDATA[  #######
  ]]> 
  </cell>
- <cell>
- <![CDATA[  #######
  ]]> 
  </cell>
- <cell>
- <![CDATA[ Program Manager 
  ]]> 
  </cell>
- <cell>
- <![CDATA[ 
  ]]> 
  </cell>
- <cell>
- <![CDATA[ 
  ]]> 
  </cell>
- <cell>
- <![CDATA[  #######
  ]]> 
  </cell>
- <cell>
- <![CDATA[ #######@#######.com
  ]]> 
  </cell>
  </row>
  </rows>[/code]

IE displays the following javascript error.

[code]Webpage error details

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; OfficeLiveConnector.1.5; OfficeLivePatch.1.3; .NET4.0C; Tablet PC 2.0)
Timestamp: Mon, 22 Nov 2010 18:41:41 UTC


Message: 'this.obj.firstChild' is null or not an object
Line: 804
Char: 45
Code: 0
URI: http://domain.com/vreg/dhtmlx/dhtmlx.js

I am just stumpped, need some help

Please try to update php file of connector with attached one.
Version which you are using incorrectly detects first-loading because of WHERE rule in your SQL code. With updated code it must work correctly.
connector_update.zip (17.4 KB)

Stan,

Thanks for the assist.

I have updated with the new code as you suggested, did not alter my code and recieved the following error.

====================================
Log started, 24/11/2010 07:11:51
====================================

Object of class GridConfiguration could not be converted to string at /vreg/dhtmlx/connector/tools.php line 90

!!!Uncaught Exception
Code: 0
Message: Incorrect method assigned to event: :defineOptions

When I comment out the congig statements in my code the error does not occur however, I still get the following JS error.

[code]Webpage error details

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; OfficeLiveConnector.1.5; OfficeLivePatch.1.3; .NET4.0C; Tablet PC 2.0)
Timestamp: Wed, 24 Nov 2010 12:53:57 UTC

Message: ‘this.obj.firstChild’ is null or not an object
Line: 804
Char: 45
Code: 0
URI: /vreg/dhtmlx/dhtmlx.js

Message: ‘this.obj.firstChild’ is null or not an object
Line: 804
Char: 45
Code: 0
URI: /vreg/dhtmlx/dhtmlx.js

[/code]

Not quite sure what is the reason of problem, because the same code as in your case, works correctly locally.

Latest version of connector-php is attached.
codebase.zip (57.2 KB)

Stanislav,

The latest files you sent seem to have worked, my grid now load as I need however, they do not update and do not throw any errors when I try to update.

I included the debugger and it shows the following:

Log:
 row 41 marked [updated,valid]
 Initiating data sending for all rows 
 Sending all data at once
 Server url: contactconnector.php?editing=true parameters
_dhx_trim Server response received details
<?xml version='1.0' ?><data></data>

The connector code is as follows:

	require_once("config.php");
	$res=mysql_connect($mysql_server,$mysql_user,$mysql_pass);
	mysql_select_db($mysql_db);

	require("dhtmlx/connector/grid_connector.php");

	$grid = new GridConnector($res);
	$grid->enable_log("temp.log",true);
	$grid->dynamic_loading(10);

	$config = new GridConfiguration();
	$config->setHeader(array("ID","First Name","Last Name","Title","Office","Extn","Mobile","Email"));
	$config->setColTypes("ed,ed,ed,ed,ed,ed,ed,ed");
	$grid->set_config($config);

	if ($grid->is_select_mode()){//code for loading data
       $grid->render_sql("Select * from vendor_registration_contact WHERE VEND_REG_ID=".$SelectID, "VEND_CONT_ID","VEND_REG_ID,VEND_FNAME,VEND_LNAME,VEND_TITLE,VEND_PHONE,VEND_EXTN,VEND_MOBILE,VEND_EMAIL1");
    }else{//code for other operations - i.e. update/insert/delete
		$grid->render_table("vendor_registration_contact","VEND_CONT_ID","VEND_REG_ID,VEND_FNAME,VEND_LNAME,VEND_TITLE,VEND_PHONE,VEND_EXTN,VEND_MOBILE,VEND_EMAIL1");
	}

My Javascript is as follows:

        dhxLayoutProfile.cells("b").setText(AddContactRowButton+RemoveContactRowButton+SaveContactRowButton);
		var dhxLayoutProfileCollText = dhxLayoutProfile.setCollapsedText("b", "Contacts");
        //dhxLayoutProfile.cells("b").fixSize(true, true);
        dhxLayoutProfile.cells("b").setHeight(200);
        myGridContact = dhxLayoutProfile.cells("b").attachGrid();
        myGridContact.setImagePath("dhtmlx/imgs/");
		myGridContact.loadXML("contactconnector.php");
        dpGridContact = new dataProcessor("contactconnector.php");
		dpGridContact.setTransactionMode("POST",true);
		dpGridContact.setUpdateMode("off");
		dpGridContact.enablePartialDataSend(true);
        dpGridContact.init(myGridContact);

I suspect it may be something simple that I am not seeing…

The next line in your client side code need to be removed

dpGridContact.enablePartialDataSend(true);

Also check that
a) dhtmlxconnector.js is included
b) dhtmlxconnector.js is included after dataprocessor.js

Stanislav,

Thanks, your comment got me thinking and I sorted it out; when I incoporated the updated codebase you sent I had the processor.js and connector.js in different folders (stupid me).

Anyway, I think I’m getting the hang of it.