column dropdown from a select

Questionscolumn dropdown from a select
Mario asked 8 years ago

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

4 Answers
Abu Ghufran answered 8 years ago

Hi,

This code snippet looks fine. If you share full grid code, i can further review it.

Mario answered 8 years ago

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.

Abu Ghufran answered 8 years ago

Can we have a webex remote meeting now?
I'm still unable to understand.

Mario answered 8 years ago

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.

Your Answer

15 + 0 =

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?