我一直在测试openjs grid 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);
}
?>
index.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、位置、阵型、控制台等...
最佳答案
开发者很友善地回答了我在 github 上的问题!
在您的表 html 中,设置 type="text"- 它在原始文档中被省略,现在将被添加。
<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>
应该是
<table class="grid users" action="ajax.php">
<tr>
<th col="id" width="50">id</th>
<th col="ForumID">ForumID</th>
<th type="text" col="GTPSN">GTPSN</th>
<th type="text" col="Position">Position</th>
<th type="text" col="Formation">Formation</th>
</tr>
</table>
向这个伟大工具的开发者致敬。对于构建后端管理控制面板的任何人来说都是一个极好的补充!
关于javascript - openjs grid v2.1 - 可编辑列不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14410449/