Connector_select_filter is not working

I maked server side select filter.


The first loading was successful but It is not working on select mode…
When I select a pattern name item, query the error occurred.
Query error are seen as conditional alias problem.

I Wanted a query like this…

SELECT
d.last_detect_date,
d.pattern_name,
p.ptn_level,
d.matched_data,
d.req_url,
g.group_name,
s.url,
c.channel_name
FROM detect_info d
LEFT JOIN seed_domain s ON d.seed_id = s.seed_id
LEFT JOIN pattern_list p ON d.pattern_name = p.pattern_name
LEFT JOIN group_info g ON s.group_id = g.group_id
LEFT JOIN channel_info c ON g.p_channel_id = c.channel_id
WHERE d.pattern_name LIKE ‘%google%’ OFFSET 0 LIMIT 100

However, the server script creates the following query…


LEFT JOIN pattern_list p ON d.pattern_name = p.pattern_name
LEFT JOIN group_info g ON s.group_id = g.group_id
LEFT JOIN channel_info c ON g.p_channel_id = c.channel_id
LEFT JOIN channel_info c ON g.p_channel_id = c.channel_id
WHERE pattern_name LIKE ‘%google%’ OFFSET 0 LIMIT 100

client code.

grid.setHeader(["No","Date","Event","Risk","Matching Data","Request Url","Channel","Group","Seed Domain"]);
	grid.setColTypes("cntr,ro,ro,ro,ro,ro,ro,ro,ro");	
	//grid.setColSorting('str,str');
	//grid.attachHeader(" ,#text_search,#connector_select_filter,#select_filter,#text_search,#text_search,#select_filter,#select_filter,#text_search");
	grid.attachHeader(" , ,#connector_select_filter");
	grid.setInitWidths('40,100,100,60,350,300,100,100,*');
	grid.init();
	grid.enableSmartRendering(true);
	grid.load("/source/event/grid/malware_grid_connector.php");

Server side code.

[code] $conn = get_db_connection();
$grid = new GridConnector($conn,“Postgre”);
$grid->dynamic_loading(100);

$grid->enable_log("temp.log");

$filter1 = new OptionsConnector($conn,"Postgre");
$filter1->render_sql("select pattern_name as value, pattern_name as label from pattern_list",
					 "pattern_name","pattern_name(value),pattern_name(label)");
					 
$grid->set_options("pattern_name",$filter1);
			$sql = "SELECT 
			d.last_detect_date, 
			d.pattern_name, 
			p.ptn_level, 
			d.matched_data, 
			s.req_url, 
			g.group_name, 
			s.url, 
			c.channel_name 
		FROM detect_info d
		LEFT JOIN seed_domain s	 ON d.seed_id = s.seed_id
		LEFT JOIN pattern_list p ON d.pattern_name = p.pattern_name
		LEFT JOIN group_info g	 ON s.group_id = g.group_id
		LEFT JOIN channel_info c ON g.p_channel_id = c.channel_id";		
 	
$grid->render_sql($sql,"id","'', last_detect_date, pattern_name, ptn_level,matched_data,
		req_url,channel_name,group_name,url");[/code]

So I try to another query.
The newly created query is not using an alias.
This query does not display grid items…


[code]$filter1 = new OptionsConnector($conn,“Postgre”);
$filter1->render_sql(“select pattern_name as value, pattern_name as label from pattern_list”,
“pattern_name”,“pattern_name(value),pattern_name(label)”);

$grid->set_options("pattern_name",$filter1);
		
$sql = "SELECT 
			detect_info.last_detect_date, 
			detect_info.pattern_name, 
			pattern_list.ptn_level, 
			detect_info.matched_data, 
			detect_info.req_url, 
			group_info.group_name, 
			seed_domain.url, 
			channel_info.channel_name 
		FROM detect_info 
		LEFT JOIN seed_domain 	 ON detect_info.seed_id = seed_domain.seed_id
		LEFT JOIN pattern_list   ON detect_info.pattern_name = pattern_list.pattern_name
		LEFT JOIN group_info 	 ON seed_domain.group_id = group_info.group_id
		LEFT JOIN channel_info   ON group_info.p_channel_id = channel_info.channel_id";		
 	
$grid->render_sql($sql,"id",
			"'', 
			detect_info.last_detect_date, 
			detect_info.pattern_name, 
			pattern_list.ptn_level, 
			detect_info.matched_data, 
			detect_info.req_url, 
			group_info.group_name, 
			seed_domain.url, 
			channel_info.channel_name");[/code]

…How can I do…
Thank you…

Hi,

You can use beforeFilter server side events, from this event you can define your own SQL code, used for the filtering.

docs.dhtmlx.com/connector__php__ … nipulation

function custom_filter($filter_by){ $index = $filter_by->index("some_field"); if ($index!==false) $filter_by->rules[$index]["name"]="d.".$filter_by->rules[$index]["name"]; } $conn->event->attach("beforeFilter","custom_filter");