Hello,
I want to use a colums as a dropdown. I looked for sample. The select is working:
select cetc.campaign_id as k, cec.title as v from categories_email_to_campaigns cetc left join categories_email_campaigns cec on cec.campaign_id = cetc.campaign_id ist working.
But how do I get it into the columndropdown, if not like:
————————
$col = array();
$col["title"] = "Kampagnenid";
$col["name"] = "campaign_id";
$col["dbname"] = "categories_email_to_campaigns.campaign_id"; // this is required as we need to search in name field, not id
$col["width"] = "21";
$col["align"] = "left";
$col["search"] = false;
$col["editable"] = true;
$col["edittype"] = "select"; // render as select
# fetch data from database, with alias k for key, v for value
$str = $g->get_dropdown_values("select cetc.campaign_id as k, cec.title as v from categories_email_to_campaigns cetc left join categories_email_campaigns cec on cec.campaign_id = cetc.campaign_id");
$col["editoptions"] = array("value"=>":;".$str);
$col["editoptions"]["dataInit"] = "function(){ setTimeout(function(){ $('select[name=campaign_id]').select2({width:'80%', dropdownCssClass: 'ui-widget ui-jqdialog'}); },200); }";
$cols[] = $col;
———
Did I miss anything to make the dropdown work?
Thanx and best regards, Mario
Hi,
This code snippet looks fine. If you share full grid code, i can further review it.
cool.
I commented this codefragment out out here:
live ersion until know:
http://bit.ly/29HTGKB
I like to advise an Email category with the dropdown, instead of writing it directly in the cell, which reduces typeing.
Thank you for your time, I found out, the problem was in this dynamic code line, even if it works independently, but I could not connect with whole code:
$str = $g->get_dropdown_values("select campaign_id as k, ' as v from categories_email_to_campaigns left join categories_email_campaigns cec on cec.campaign_id = categories_email_to_campaigns.campaign_id");
A "fixed" list however is working:
$col["editoptions"] = array("value"=>'1400:Technik;600:Versandstatus;100:Lagerstand;500:Bestellwesen;1000:Abonnement;900:Upselling;700:Zahlungstatus;800:Produktbeilagen;1100:Kundenkonto;200:Aquise');
Thus I generated this onetime list with:
select distinct concat(cetc.campaign_id,':', cec.title,';') from categories_email_to_campaigns cetc left join categories_email_campaigns cec on cec.campaign_id = cetc.campaign_id
And now it works 🙂
later ist would be nice, if one could use the concat-code also in the above
$str = $g->get_dropdown_values, just as an idea.