A working multiple-choices lookup (illimited choices from another table)

The recommended method of customizing your AppGini-generated application is through hooks. But sometimes you might need to add functionality not accessible through hooks. You can discuss this here.
Post Reply
samrainbow
Posts: 11
Joined: 2015-09-24 14:06

A working multiple-choices lookup (illimited choices from another table)

Post by samrainbow » 2016-12-09 19:45

Hello everybody,

I've managed (not without what we could call "hard efforts"...) to make a working multiple-choices lookup.
Within a certain field in Detail-view, you can easily pick up as many choices as you want from another table using the select2 component.
In the Table-view, all the selected choices for the multiple-choices field are listed for each row.
Currently, the quick-search is supported but no filter can be applied on the "multiple-choices" field nor even combined with one or many other filters working on the other fields.



Image

Made with AppGini v5.51

You can test it (add and edit your own records) at the following URL :

http://recoin.org/testdb/
Username : testuser
Password : 123456

Enjoy !

yaroing
Posts: 3
Joined: 2016-12-14 10:04

Re: A working multiple-choices lookup (illimited choices from another table)

Post by yaroing » 2016-12-14 10:08

Yes!
Exactly what I am looking for. How do You procede in order to make it?

Très intéressant comme outil.

hpiedcoq
Posts: 1
Joined: 2017-01-14 08:12

Re: A working multiple-choices lookup (illimited choices from another table)

Post by hpiedcoq » 2017-01-14 08:13

I'm also very interested by this hook.

Could you share your code somehow, please?

Thanks

User avatar
landinialejandro
AppGini Super Hero
AppGini Super Hero
Posts: 126
Joined: 2016-03-06 00:59
Location: Argentina
Contact:

Re: A working multiple-choices lookup (illimited choices from another table)

Post by landinialejandro » 2017-01-30 01:14

Hello, I wrote the following code in:
tablename_dml.php

Code: Select all

	// combobox: TAG (TAG is the name field in the tablename)
	$combo_TAG = new Combo;
	$combo_TAG->ListType = 3;
	$combo_TAG->MultipleSeparator = ', ';
	$combo_TAG->ListBoxHeight = 10;
	$combo_TAG->RadiosPerLine = 1;
	if(is_file(dirname(__FILE__).'/hooks/Materiales.TAG.csv')){
	
	// I create the file Materiales.TAG.csv in the hook folder to activate this part of code and coment part of orginal code
//		$TAG_data = addslashes(implode('', @file(dirname(__FILE__).'/hooks/Materiales.TAG.csv')));
//		$combo_TAG->ListItem = explode('||', entitiesToUTF8(convertLegacyOptions($TAG_data)));

// this is the added part
                $res = sql("SELECT Nombre FROM Categorias", $eo);
                while($row = db_fetch_array($res))
                {
                    $inspector[] = $row['Nombre'];
                }
                $combo_TAG->ListItem = $inspector;

// to here
		$combo_TAG->ListData = $combo_TAG->ListItem;
	}else{
		$combo_TAG->ListItem = explode('||', entitiesToUTF8(convertLegacyOptions("A;;B;;C;;D;;E;;"))); // this is the original list of elements
		$combo_TAG->ListData = $combo_TAG->ListItem;
	}
	$combo_TAG->SelectName = 'TAG';
:| the code work fine but i don´t know if is correct.

:( Problem: the code is not in a hook file therewere is erased when compile again

thanks
Alejandro
Alejandro.
AppGini 5.98 - Linux OpenSuse Tumblewweed.

Some of my posts that may interest you:
:arrow: Landini Admin Template: Template for Appgini like AdminLTE
:arrow: Profile image plugin: add and changue image user profile
:arrow: Field editor in table view: Configurable fast edit fields in TV
:idea: my personal page

User avatar
dilitimor
Veteran Member
Posts: 36
Joined: 2013-01-10 02:45
Location: Jakarta, Indonesia
Contact:

Re: A working multiple-choices lookup (illimited choices from another table)

Post by dilitimor » 2017-07-26 03:24

@samrainbow as I digging detail on your page there is get_tags.php file that call in the json script part
So is not just using the select2 component

Post Reply