Custom URL Manipulation on Load

Hi there, can anyone help me about custom URL Manipulation please:?: I’ve problem about the custom URL manipulation. Here’s my script:

mygrid.loadXML(“hplan_connector.php?accid=”+document.getElementById(“AccId”).value+“&grant=”+document.getElementById(“GrantAccess”).value);

I used this script to get custom values from client side with $_GET method, so I can use these values to manipulate SQL on server side. It’s work when load the normal data, but it doesn’t work when I do the filtering action on client side (can’t filter). I think it’s because the custom URL manipulation makes error (maybe: on error resume next). Is there other way to passing the values from client side to server side without this dirty custom URL manipulation?

The way how you are adding params to the url is fully legal and must not cause problems for the filtering or other functionality. (connector will add their own parameters after any existing one, it expects that url already may contains custom parameters)

it doesn’t work when I do the filtering action on client side (can’t filter)
You are using server side filtering, with connectors, right?
Try to enable the server side logs and post here the output during incorrect filtering operation.

docs.dhtmlx.com/doku.php?id=dhtm … nd_logging

Yes, I’m using server side filtering. I have been monitored the log, but the connector doesn’t add their own parameters after any existing one.

This is my client side code :

  <script>
  	//init grid and set its parameters (this part as always)  	
  	mygrid = new dhtmlXGridObject('hplangrid');
  	mygrid.setImagePath("../../js/dhtmlxGrid/codebase/imgs/");
  	mygrid.setHeader("Action,Job Title,Position,Degree,Urgency,Hiring Program,Experience,Open For,Date Created");
  	mygrid.setInitWidths("50,*,80,80,90,90,110,180,90");
  	mygrid.setColAlign("center,left,left,center,left,left,left,left,center");
  	mygrid.setColTypes("ro,ro,ro,ro,ro,ro,ro,ro,ro");
  	mygrid.setSkin("dhx_skyblue");
  	mygrid.attachHeader("#rspan,#connector_text_filter,#connector_text_filter,#connector_text_filter,#connector_text_filter,#connector_text_filter,#connector_text_filter,#connector_text_filter,#connector_text_filter");
  	mygrid.setColSorting("str,str,str,str,str,str,str,str,connector")
  	mygrid.init();
  	mygrid.enableSmartRendering(true);
  	mygrid.enableMultiselect(true);  	
  	mygrid.loadXML("hplan_connector.php?accid="+document.getElementById("AccId").value+"&grant="+document.getElementById("GrantAccess").value+"");
  	
  //============================================================================================
  	myDataProcessor = new dataProcessor("hplan_connector.php"); //lock feed url
  	myDataProcessor.setTransactionMode("POST",true); //set mode as send-all-by-post
  	myDataProcessor.setUpdateMode("off"); //disable auto-update
  	myDataProcessor.init(mygrid); //link dataprocessor to the grid
  //============================================================================================
  </script>	

And this is my server side code :

require_once("../js/dhtmlxConnector_php/codebase/grid_connector.php");	
  require_once "../config/connection.php";
  
	$accid = $_GET['accid'];	  
	
	function formatting($row){
    require_once "../config/function.php";
    //render field as details link
    $data = $row->get_value("IdAdv");
    $accid = $row->get_value("AccId");
    $ecnkey = $row->get_value("ecnkey");
    $grant = $row->get_value("AccessGrant");
    list($InputGrant,$UpdateGrant,$DeleteGrant,$ViewGrant) = explode("%",decrypt($grant,$ecnkey));
    if ($UpdateGrant==1)  {$edit=" <a href='".form_action("edit",$data,$accid,$ecnkey,"")."'><img src='../../images/edit.gif' style='border:none' title='Edit' alt='Edit'width='12px'/></a>";}    
    $row->set_value("x","<a href='".form_action("view",$data,$accid,$ecnkey,"")."'><img src='../../images/details.gif' style='border:none' title='Details' alt='Details' width='12px'/></a> $edit");
  
    //formatting date field
    $data = $row->get_value("CreatTime");
    $row->set_value("CreatTime",date("d/m/Y",strtotime($data)));
	}
 	
	//(SELECT FullName FROM cvopr_aco WHERE AccId=RoutePDC) AS FullName
  $sql="SELECT IdAdv,JobTitle,PosCat,EduDegree,InfoHir,HiringProg,GradExpe,OpenFor,CreatTime    
    ,'x','$accid' AS AccId,'$ecnkey' AS ecnkey, '$_GET[grant]' AS AccessGrant
    FROM cvjob_adv WHERE CreatBy='$accid' AND ApprPDC='0'";    

	$grid = new GridConnector();
	$grid->event->attach("beforeRender","formatting");	
  $grid->set_encoding("ISO-8859-1");
	$grid->dynamic_loading(100);	
  $grid->enable_log("e:/connectorlog.txt",true);		
  $grid->render_sql($sql,"IdAdv","x,JobTitle,PosCat,EduDegree,InfoHir,HiringProg,GradExpe,OpenFor,CreatTime");

And this is the log after I do the filtering action :

====================================
Log started, 11/05/2011 09:05:31
====================================

Ready for SQL generation
field => 
	0 => 
		0 => x
		1 => x
	1 => 
		0 => JobTitle
		1 => JobTitle
	2 => 
		0 => PosCat
		1 => PosCat
	3 => 
		0 => EduDegree
		1 => EduDegree
	4 => 
		0 => InfoHir
		1 => InfoHir
	5 => 
		0 => HiringProg
		1 => HiringProg
	6 => 
		0 => GradExpe
		1 => GradExpe
	7 => 
		0 => OpenFor
		1 => OpenFor
	8 => 
		0 => CreatTime
		1 => CreatTime
id => 
	0 => IdAdv
	1 => IdAdv
table => 
	0 =>  cvjob_adv 
	1 =>  cvjob_adv 
count => 100

Exec SQL: SELECT  COUNT(*)  FROM  cvjob_adv  WHERE  CreatBy='2011041211220518' AND ApprPDC='0'

Exec SQL: SELECT  IdAdv,JobTitle,PosCat,EduDegree,InfoHir,HiringProg,GradExpe,OpenFor,CreatTime    
    ,'x','2011041211220518' AS AccId,'xaxaxa' AS ecnkey, 'mpiVVmWTng' AS AccessGrant
     FROM  cvjob_adv  WHERE  CreatBy='2011041211220518' AND ApprPDC='0' LIMIT 0,100

Done in 0.0240359306335ms

The log after filtering action show that isn’t any additional params which generated by the connector. So there’s the same log information on before and after filtering action.

I’ve tried to modify my code with connector=true :

mygrid.loadXML("hplan_connector.php?connector=true&accid="+document.getElementById("AccId").value+"&grant="+document.getElementById("GrantAccess").value+"");

But with this way, I’ve get lost my passing value. Here is the log with connector=true :

====================================
Log started, 11/05/2011 09:05:33
====================================

Ready for SQL generation
field => 
	0 => 
		0 => x
		1 => x
	1 => 
		0 => JobTitle
		1 => JobTitle
	2 => 
		0 => PosCat
		1 => PosCat
	3 => 
		0 => EduDegree
		1 => EduDegree
	4 => 
		0 => InfoHir
		1 => InfoHir
	5 => 
		0 => HiringProg
		1 => HiringProg
	6 => 
		0 => GradExpe
		1 => GradExpe
	7 => 
		0 => OpenFor
		1 => OpenFor
	8 => 
		0 => CreatTime
		1 => CreatTime
id => 
	0 => IdAdv
	1 => IdAdv
table => 
	0 =>  cvjob_adv 
	1 =>  cvjob_adv 
rules => 
	0 => 
		0 => HiringProg
		1 => inter
count => 100

Exec SQL: SELECT  COUNT(*)  FROM  cvjob_adv  WHERE  CreatBy='' AND ApprPDC='0' AND HiringProg LIKE '%inter%'

Exec SQL: SELECT  IdAdv,JobTitle,PosCat,EduDegree,InfoHir,HiringProg,GradExpe,OpenFor,CreatTime    
    ,'x','' AS AccId,'xaxaxa' AS ecnkey, '' AS AccessGrant
     FROM  cvjob_adv  WHERE  CreatBy='' AND ApprPDC='0' AND HiringProg LIKE '%inter%' LIMIT 0,100

Done in 0.0162718296051ms

So what should I do to fix this problem?

Please try to update connector.js with the attached one.
This is latest version with all fixes up to date, and code similar to above one works correctly with it.
connector.zip (1.49 KB)

It doesn’t work yet, I was try to update only the connector.js but doesn’t work. And then I try to update a whole of connector codebase with dhtmlxConnector_v10_php and update connector.js with file that you give. But it still doesn’t work. And the log shown like below :

//BEFORE FILTERING WITH CONNECTOR=TRUE
====================================
Log started, 13/05/2011 10:05:12
====================================

SELECT  IdAdv,JobTitle,PosCat,EduDegree,InfoHir,HiringProg,GradExpe,OpenFor,CreatTime    
    ,'x','2011041211220518' AS AccId,'xaxaxa' AS ecnkey, 'mpiVVmWTng' AS AccessGrant
 FROM cvjob_adv WHERE  CreatBy='2011041211220518' AND ApprPDC='0' LIMIT 0,100

SELECT COUNT(*) as DHX_COUNT  FROM cvjob_adv WHERE  CreatBy='2011041211220518' AND ApprPDC='0'

Done in 0.00937390327454s


//AFTER FILTERING WITH CONNECTOR=TRUE
====================================
Log started, 13/05/2011 10:05:02
====================================

SELECT  IdAdv,JobTitle,PosCat,EduDegree,InfoHir,HiringProg,GradExpe,OpenFor,CreatTime    
    ,'x','' AS AccId,'xaxaxa' AS ecnkey, '' AS AccessGrant
 FROM cvjob_adv WHERE  CreatBy='' AND ApprPDC='0' AND HiringProg LIKE '%In%' LIMIT 0,100

SELECT COUNT(*) as DHX_COUNT  FROM cvjob_adv WHERE  CreatBy='' AND ApprPDC='0' AND HiringProg LIKE '%In%'

Done in 0.00805997848511s


//BEFORE FILTERING WITHOUT CONNECTOR=TRUE
====================================
Log started, 13/05/2011 10:05:58
====================================

SELECT  IdAdv,JobTitle,PosCat,EduDegree,InfoHir,HiringProg,GradExpe,OpenFor,CreatTime    
    ,'x','2011041211220518' AS AccId,'xaxaxa' AS ecnkey, 'mpiVVmWTng' AS AccessGrant
 FROM cvjob_adv WHERE  CreatBy='2011041211220518' AND ApprPDC='0' LIMIT 0,100

SELECT COUNT(*) as DHX_COUNT  FROM cvjob_adv WHERE  CreatBy='2011041211220518' AND ApprPDC='0'

Done in 0.0093789100647s


//AFTER FILTERING WITHOUT CONNECTOR=TRUE
====================================
Log started, 13/05/2011 10:05:06
====================================

SELECT  IdAdv,JobTitle,PosCat,EduDegree,InfoHir,HiringProg,GradExpe,OpenFor,CreatTime    
    ,'x','2011041211220518' AS AccId,'xaxaxa' AS ecnkey, 'mpiVVmWTng' AS AccessGrant
 FROM cvjob_adv WHERE  CreatBy='2011041211220518' AND ApprPDC='0' LIMIT 0,100

SELECT COUNT(*) as DHX_COUNT  FROM cvjob_adv WHERE  CreatBy='2011041211220518' AND ApprPDC='0'

Done in 0.0124070644379s

Before update to dhtmlxConnector_v10_php, the array is shown in log. After the update, array not shown in log. But the result remain the same.

whether there is a shortage or something I did wrong so that filtering can not work?

Full working sample is attached ( latest js files and latest grid ) - try to use it with your config and in your environment

Attached sample uses custom param in url, and as you can see - using it with server side filters doesn’t cause problems ( parameter still exists in url and still sent to server side )
1305288871.zip (113 KB)

Thank you Stanislav… It’s worked now. Thank’s for the help. :slight_smile: