Filter for Multi-select by SelectedID

Discussions related to customizing hooks. Hooks are documented at http://bigprof.com/appgini/help/advanced-topics/hooks/
Post Reply
kerelov
Veteran Member
Posts: 42
Joined: 2020-04-17 21:20
Location: Bulgaria

Filter for Multi-select by SelectedID

Post by kerelov » 2020-04-22 17:55

Hi guys,
This topic about the multi-select lookup fields was very helpful:
https://bigprof.com/blog/appgini/a-work ... gini-apps/

With just a slight change it works nice to filter by the SelectedID or any other field in DV:
You just need to call the function once in the yourtable_init function in yourtable.php hook file like this:

Code: Select all

function proceedings_init(&$options, $memberInfo, &$args) {
		update_parties_list();

		return TRUE;
	}
This way the CSV file is updated every time you enter DV and shows only the data connected to this record
And my function looks like this:

Code: Select all

function update_parties_list()
	{
		if($_POST['SelectedID']!='')
		{
			$parties = array();
			$res = sql("SELECT `parties`.`name` AS pname, `participant_types`.`name` AS tname FROM `parties`, `participant_types`, 		`participants`, `proceedings` WHERE 
			`proceedings`.`id` = '".$_POST['SelectedID']."' AND `participants`.`case` = `proceedings`.`case` AND `participants`.`party` = `parties`.`id` AND 
			`participants`.`participant_type` = `participant_types`.`id`", $eo);
			while($row = db_fetch_assoc($res))
				$parties[] = $row['tname']." - ".$row['pname'];
		 
			// save the parties to the options list file
			$list_file = dirname(__FILE__) . '/proceedings.parties.csv';
			@file_put_contents($list_file, implode(';;', $parties));
		}
	}
	
This is very good but now it will be even better to implement a workaround for multi-select that will be filtered by a previously selected option in another select field. This probably will work good with AJAX and .js magic files. If someone already have a solution please post it.

Post Reply