Page 1 of 1

Multiple-choice list box from table

Posted: 2020-02-13 09:00
by baudwalker
Is the a way to set up a Multiple-choice list box, similar to what is available in the options list, but the selections are from a table field in stead of using the options list?

Re: Multiple-choice list box from table

Posted: 2020-02-13 10:06
by G Belgrado
Yes, this page https://bigprof.com/blog/appgini/a-work ... gini-apps/
describes how to create a selection from table data

Re: Multiple-choice list box from table

Posted: 2020-02-13 22:05
by baudwalker
Thank you for point this out I will see if it can be implemented in my situation

Re: Multiple-choice list box from table

Posted: 2021-01-30 03:48
by baudwalker
This has been working fine, but now I have another project that I wish to populate multi-choice list by adding records to the table but with a further twist.

Each user will have a different list created by their own table entries. I would require something like {tablename}.{fieldname}.{user}.csv. can this be done?

Re: Multiple-choice list box from table

Posted: 2021-01-30 16:25
by onoehring
Hi baudwalker,

I think I have a similar problem described here ( viewtopic.php?f=2&t=4098 ) - but have not gotten any solution so far.
There is some possibility I am considering at this time which I will describe in a second.
Some ideas first:

a) Why not follow the idea pbötcher's link (to the blog) holds, but extend the 'tags' table by another column 'customer'. Depending on how busy your table is, you might pull only those 'tags' from that table that match the customer and write those to the file.

b) You should take a look at the AG functions that are looking for that csv on your server. Probably it should be quite easy to change that function to use the name-extension you are suggesting. One drawback: That function will probably be overwritten when you regenerate your app in AG.
A quick check on one of my applications shows that this seems to be in the (not hooks directory) /tablename_dml.php file. Look for the function

Code: Select all

function YourTablename_form(
There you find something like

Code: Select all

if(is_file(dirname(__FILE__).'/hooks/YourTablename.YourFieldName.csv')) {
$YourFieldName_data = addslashes(implode('', @file(dirname(__FILE__).'/hooks/YourTablename.YourFieldName.csv')));
You should be able to apply your suggestion there, something like this:

Code: Select all

if(is_file(dirname(__FILE__).'/hooks/YourTablename.YourFieldName.csv')) {
$mi = getMemberInfo();
$username = $mi['username'];
$YourFieldName_data = addslashes(implode('', @file(dirname(__FILE__).'/hooks/YourTablename.YourFieldName.' . $username  . '.csv')));
Remember: The file will be overwritten when the app is being recreated.



.... well, so only theory, not tested!

Olaf

Re: Multiple-choice list box from table

Posted: 2021-02-01 04:06
by baudwalker
Thank you Olaf

That looks like what I require.

The database is very active on certain day with about 1000 users. Each may have their own .csv file.

I will have a go at you idea in a few days and see how I go.

Barry