Skip to content

Instantly share code, notes, and snippets.

@optikalefx
Created October 31, 2012 16:40
Show Gist options
  • Save optikalefx/3988161 to your computer and use it in GitHub Desktop.
Save optikalefx/3988161 to your computer and use it in GitHub Desktop.
Open JS Grid Drop Downs
<?php
// require our class
require_once("grid.php");
// load our grid with a table
$grid = new Grid("tutorials", array(
"save"=>true,
"select" => 'selectFunction'
));
// if you have anonymous function support in PHP (5.3.2+) Then you can just write the
// Function above instead of creating a separate one here.
function selectFunction($grid) {
$selects = array();
// category select
$grid->table = "categories";
$selects["CategoryID"] = $grid->makeSelect("CategoryID","Name");
// active select
$selects["active"] = array("1"=>"true","0"=>"false");
// render data
$grid->render($selects);
}
?>
<script>
$(function() {
$(".users").grid({
editing:true
});
});
</script>
<table class="demo demo4" action="ajax2.php">
<tr>
<th col="Title">Title</th>
<th col="CategoryID" width="250" type="select">Drop down from another table</th>
<th col="active" width="200" type="select">Hardcoded drop down</th>
</tr>
</table>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment