optikalefx / OpenJS-Grid

OpenJS Grid is the easiest jQuery Grid ever. With very little work you can have a data grid that can do everything from sorting and searching to complex database queries. Best of all, its open source. So you can learn how it's all done.
http://square-bracket.com/openjs
MIT License
96 stars 46 forks source link

One field. #47

Closed ctahk0 closed 10 years ago

ctahk0 commented 10 years ago

Hi, can you please show me how to select only one field from database? I'm little confused about where to put select query.. Here is my code (and won't work of course) :) thanks.

$grid = new Grid("tblitems", array(
    "save"=>true,
    "delete"=>true,
    "where"=>"codeID != ''",
    "select" => 'selectFunction'
));

// 'selectFunction'
function selectFunction($grid) {
    $selects = array();

    $grid->table = "tblitems";
    $selects["codeID"] = $grid->makeSelect("codeID");

    // active select
    $selects["active"] = array("1"=>"true","0"=>"false");

    // render data          
    $grid->render($selects);
}
optikalefx commented 10 years ago

You're thinking too hard about it. The HTML dictates the fields you select from the table.

<th col="oneField"></th>

That will select that field from your tblitems table. The "select" is for select boxes, in other words, a combo box.