Populate multi select2 dropdown based on selected row

QuestionsPopulate multi select2 dropdown based on selected row
Steven Borruso asked 6 years ago

I’m creating a grid to allow creation of a Weekly Meals Menu for an institution that, (by law) must create and  save these menus each week.

The grid has as the first column the “Meal Type” (with static values “Brkfst”, “Lunch”, “Dinner”) and these values will never change and will have a static id that will match the rowids in the grid (1-3).

The rest of the columns represent the 7 days of the week (“Sun”-“Sat”).

I want to have each day of the week column have a multi-select2 control which dynamically gets populated with “food” values based on which row (Brkfst,Lunch,Dinner) is currently selected.

I haven’t found any examples of this so tried to come up with the beginnings of a design ….

  1. In PHP create an array of dropdown “food” values for each of the 3 known rows (Bkfst,Lunch,Dinner)
  2. Save the 3 arrays as JS arrays in the PHP file
  3. Use the $opt[“onSelectRow”] grid option that calls a “do_onselect” JS function
  4. For each of the days of the week cols define a blank multi select2 dropdown
  5. When the onSelectRow event trips, somehow build the select2 dropdown using the previously saved arrays based on the currently selected row (assuming the current rowid can be discovered)

Option 2 –

Leave out step 3 above and somehow handle building the custom select dropdown values  in the existing link_select2 function that handles the select2 objects.

Any advice, comments on if I’m way off here or suggestions for alternate approaches/examples would be highly appreciated.

Thanks,

Steve

2 Answers
Abu Ghufran Staff answered 6 years ago

Hello Steve,

This ticket remain unanswered due to an issue on our side.
Let us know if this case is still valid and need to be resolved.

_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
Steven Borruso answered 5 years ago

Abu … sorry for the delayed reponse.

I took a different approach by switching the columns for rows in the UI … and then when the grid is saved/printed I wrote (a lot) of custom TCPDF code to change the rows/columns to the way the client needs them.  So I’m good to go with the approach I implemented.

Thanks !

Steve

 

Your Answer

10 + 19 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?