我使用来自www.editablegrid.net的editablegrid,并注意到我的网格工作得很好,只要我的表有列id,这是主键。当我在另一个以custID为键的表上使用它时,它无法更新。
我哪里做错了?
如果你不给我们看你的代码片段,我们也帮不上什么忙。让我大胆猜测一下。editablegrid默认使用ID列。如果没有列ID
就需要定义它插件有一些默认设置属性,你已经玩过了吗?由于插件没有任何文档,脚本中也没有任何关于将列定义为主ID的内容,因此我建议您转向文档更好的数据网格,如http://www.datatables.net/
var props = {
name: "",
label: "",
editable: true,
renderable: true,
datatype: "string",
unit: null,
precision: -1, // means that all decimals are displayed
nansymbol: '',
decimal_point: ',',
thousands_separator: '.',
unit_before_number: false,
bar: true, // is the column to be displayed in a bar chart ? relevant only for numerical columns
headerRenderer: null,
headerEditor: null,
cellRenderer: null,
cellEditor: null,
cellValidators: [],
enumProvider: null,
optionValues: null,
columnIndex: -1
};
你应该在很多地方修改
对于loaddata.php中的delete Action
$grid->addColumn('action', 'Action', 'html', NULL, false, 'id');
更改为
$grid->addColumn('action', 'Action', 'html', NULL, false, 'yourprimarykey');
in update.php(第39行)
if ( $stmt = $mysqli->prepare("UPDATE ".$tablename." SET ".$colname." = ? WHERE id = ?")) {
更改为
if ( $stmt = $mysqli->prepare("UPDATE ".$tablename." SET ".$colname." = ? WHERE yourprimarykey = ?")) {
在delete.php if ( $stmt = $mysqli->prepare("DELETE FROM ".$tablename." WHERE id = ?")) {
更改为
if ( $stmt = $mysqli->prepare("DELETE FROM ".$tablename." WHERE yourprimarykey = ?")) {