Database dropdown field is a pipe seperated list.

QuestionsDatabase dropdown field is a pipe seperated list.
CB asked 4 days ago

Hi

Is it possible to query a table of data with pipe delimited fields, then break that field into an array for the dropdown specifically for the row being referred to ? apart from using a SQL lookup for each row. ?

Or is it possible to refer to a field value in a column formatter?

Example is I have multiple values against a record, I want users to choose the correct value for each row.

 

2 Answers
Abu Ghufran Staff answered 3 days ago

Hi,

Please refer to this code:

https://gist.github.com/gridphp/53485c7be70df244d950fc36e810a01d

Step1, line 32-47: Makes tab separated value to dropdown required format

Step2, line 49-59: Makes a dropdown from the other field of the row

Step3, line 61-65: Make options non editable so it does not disturb step1.

_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
cb answered 2 days ago

All working – just had to add  $col[“editable”] = true; to get the dropdown to work.

$col = array();
$col[“title”] = “Answer”;
$col[“name”] = “answer”;
$col[“width”] = “100”;
$col[“edittype”] = “select”;
$col[“editable”] = true;
$col[“editoptions”][“value”] = “function(elem){
        var grid =  $(‘#list1’);
        var r = grid.getGridParam(‘selrow’);
        return grid.jqGrid(‘getCell’, r, ‘options’);
}”;
$cols[] = $col;

Your Answer

7 + 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?