PHP querystring and table deletes

Hello,

I have a grid control which calls a connector using a querystring. For sake of illustration, I’ve hard-coded the querystring value:

...
	myGrid2.init();
	myGrid2.enableSmartRendering(true);
	myDataProcessor = new dataProcessor("connectorFRST2referralsx.php"); 
	myDataProcessor.init(myGrid2);
	myDataProcessor.setUpdateMode("cell",true);
	myDataProcessor.setDataColumns("true,true,true,true,true,true");
	myGrid2.loadXML("connectorFRST2referralsx.php?contactid=1357236440287") 

The PHP connector code is:

...
		$qs = $_GET["contactid"];
		$grid = new GridConnector($res,"sqlsrv");
		$grid->dynamic_loading(100);
		$thesql = "SELECT Assistance, Referrals, ContactDate, FollowupDate, ContactID, ReferralID FROM COF_datastoretest2_tbl WHERE ContactID='".$qs."'";
		$grid->render_sql($thesql, "ReferralID", "Assistance, Referrals, ContactDate, FollowupDate, ContactID, ReferralID");

When I attempt to delete a row in the grid using this code:

...
	var selId = myGrid2.getSelectedId();
	if (selId !== null)
		{	
		retType = confirm("Are you sure you want to delete this row?"); 
	
		if (retType == true) 
			{ 	
			myGrid2.deleteSelectedRows();
			}
		}
...

… the row disappears from the grid, but not from the database table. Refreshing the webpage causes the row to reappear in the grid.

If I change this code in the PHP connector from this:

		$thesql = "SELECT Assistance, Referrals, ContactDate, FollowupDate, ContactID, ReferralID FROM COF_datastoretest2_tbl WHERE ContactID='".$qs."'";

to this:

		$thesql = "SELECT Assistance, Referrals, ContactDate, FollowupDate, ContactID, ReferralID FROM COF_datastoretest2_tbl WHERE ContactID='".1357236440287."'";

… the row is deleted from both the grid and the database table.

The dhtmlxdataprocessor_debug log is identical running both variants of the PHP connector code:

Why doesn’t the row get deleted from the table when the querystring value is held in a variable , but gets deleted when it’s hard-coded in the PHP connector, please? Is it possible to use a querystring variable in the PHP connector for performing deletes, and if so, how, please?

Thank you!

In js code you are initing 2 urls, one for data loadin ( in load command ) second for data saving ( in dataprocessor constructor ) and url in dataprocessor does miss url parameter which causes issue.

You can

a) include custom querystring in both url

or

b) on server side modify code as

if ($grid->is_select_mode()) $grid->render_sql($thesql, "ReferralID", "Assistance, Referrals, ContactDate, FollowupDate, ContactID, ReferralID"); else $grid->render_table("COF_datastoretest2_tbl ", "ReferralID", "Assistance, Referrals, ContactDate, FollowupDate, ContactID, ReferralID");

which will use incoming parameter for data loading, but will not require it for data saving.

Splendid, Stanislav, I’ll try it out. Thanks once again for your help.

I used the second solution, including an ‘if’ in the PHP wrapper. It worked great! Thanks again, Stanislav.