Select no displaying the selected value

QuestionsSelect no displaying the selected value
Cedric asked 1 year ago

Hello,

I am using this code:

$col = array();
$col[“title”] = “Phrase H 1”;
$col[“name”] = “pla_hcode1”;
$col[“width”] = “60”;
$col[“stype”] = “select”;
$col[“editable”] = true;
$col[“edittype”] = “select”; // render as select
$sqllogos=”select CONCAT(code, ‘ – ‘,REPLACE($lang, ‘;’, ‘.’)) as v, code as k FROM ghs_h_phrases”;
$str =’–:–;’. $g->get_dropdown_values($sqllogos);
$col[“editoptions”] =array(“value”=>$str);
$col[“formatter”] = “select”; // display label, not value
$col[“formatoptions”] = array(“value”=>$str);
$col[“searchoptions”] = array(“value”=>$str);
$cols[] = $col;

Its working well but the select drop down is not preseleted with the value in the table.

Is this due because I am showing label and storing different value?

 

3 Answers
Abu Ghufran Staff answered 1 year ago

Hello,

This line looks redundant:

$col["formatoptions"] = array("value"=>$str);

Second, based on the code below:

select CONCAT(code, ' – ',REPLACE($lang, ';', '.')) as v, code as k FROM ghs_h_phrases

‘code’ should be available in database as it’s the key. And value is basically shown in dropdown as label.

If it still does not work, Please share the screenshot of how the values are stored in database and how they are shown in grid.

_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
Abu Ghufran Staff answered 1 year ago

In the image, I can see it is showing correct value. If it’s not working as expected in dropdown, please share the screenshot where you are getting unexpected behavior.

_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
Your Answer

0 + 10 =

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?