ryansuitposungkono / openjs-grid

Automatically exported from code.google.com/p/openjs-grid
0 stars 0 forks source link

Select option - current value is not selected #41

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
hi again
I love the grid you've done, you saved me so much time as i just started to 
write some database management system.
I really want to get this grid working for me 100%

I'm now trying to implement select options as:
<th col="label" editable="select" width="120" nulltext="none" >Label</th>
<th col="format" editable="select" width="50">Format</th>
<th col="genre" editable="select" width="150">Genre</th>

for "label" field - none - displayed by default
for other two the value of the first element in database table.

What is the expected output? What do you see instead?

what i would like to see is current value for this field set per product in 
master table.

What version of the product are you using? On what operating system?
latest on win 7

Please provide any additional information below.

Original issue reported on code.google.com by ginger....@gmail.com on 18 Nov 2011 at 3:36

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Just to add definition in ajax:
else if(isset($_POST['select'])) {
        switch($_POST['col']) {
        case "label":
            $grid->table = "label";
            $grid->where = "label_name IS NOT NULL";
            $grid->makeSelect("Lbl_ID","label_name");
            echo json_encode($grid->data);
            break;
        case "format":
            $grid->table = "format";
            $grid->makeSelect("Fmt_ID","format_name");
            echo json_encode($grid->data);
            break;
        default:
            break;
        }
    }

Original comment by ginger....@gmail.com on 18 Nov 2011 at 3:59

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
i've figures out the solution:
grid.js
line about 894:
the comparison should be NOT to val but to disp:
$.each(options,function(val,disp) {
    //alert(disp);
    if($td.text() == disp) {
                    $select.append("<option selected value='"+val+"'>"+disp+"</option>");
    } else {
                    $select.append("<option value='"+val+"'>"+disp+"</option>");
    }
});

Original comment by ginger...@gmail.com on 22 Nov 2011 at 5:07