我一直在测试 openjs 网格 v2.1 - 从修改 ajax.php 和 index.php 开始 - 我可以让网格显示数据、删除功能、排序和导航,但我似乎无法进行内联编辑工作,我已经尝试了一切,观看了旧版本的 youtube 视频,搜索了谷歌,尝试了很多小时 - 我被卡住了!
我的表有一个主键“id”
ajax.php
<?php
// connect to db
mysql_connect("localhost","user","pass");
mysql_select_db("db");
// require our class
require_once("grid.php");
// load our grid with a table
$grid = new Grid("phpbb_rivals_players", array(
"save"=>true,
"delete"=>true,
"editing"=>true,
"where"=>"Console = 'PS3'",
"select" => 'selectFunction'
));
// drop down function
// if you have anonymous function support, then you can just put this function in place of
// 'selectFunction'
function selectFunction($grid) {
$selects = array();
// category select
$grid->table = "phpbb_rivals_players";
$selects["id"] = $grid->makeSelect("id","ForumID");
// active select
$selects["active"] = array("1"=>"true","0"=>"false");
// render data
$grid->render($selects);
}
?>
索引.php
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="bootstrap/css/bootstrap.css"/>
<link rel="stylesheet" href="grid.css" title="openJsGrid"/>
<!--<link rel="stylesheet" href="jquery-ui/css/smoothness/jquery-ui-1.8.22.custom.css"/>-->
<script src="jquery.js" type="text/javascript"></script>
<!--<script src="jquery-ui/js/jquery-ui-1.8.22.custom.min.js" type="text/javascript"></script>-->
<script src="root.js"></script>
<script src="grid.js"></script>
<script type="text/javascript">
$(function() {
$(".users").grid({
title : "users",
page : 1,
showPager : true,
editing : true,
nRowsShowing : 10,
width: 800,
editing: true,
deleting : true
}).on("loadComplete",function(e) {
//console.log("loadComplete", this.instance);
}).on("cellClick",function(e, $cell) {
//console.log("cell",$cell);
}).on("rowCheck",function(e, $checkbox) {
//console.log("rowCheck",$checkbox);
}).on("rowClick",function(e, $rows) {
//console.log("rowClick",$rows);
});
});
</script>
</head>
<body>
<h2>Players</h2>
<table class="grid users" action="ajax.php">
<tr>
<th col="id" width="50">id</th>
<th col="ForumID">ForumID</th>
<th col="GTPSN">GTPSN</th>
<th col="Position">Position</th>
<th col="Formation">Formation</th>
</tr>
</table>
</body>
</html>
我希望能够编辑 GTPSN、位置、阵型、控制台等...