下面是我的网格js的一个片段:
$grid.jqGrid({
url:'xtras/Products.php',
editurl:'xtras/Products.php',
datatype: "json",
mtype:'GET',
colModel:[...
{name:'ID',index:'catalogue.ID', hidden:true, width:10, sortable:false, editable:true, key:true},
....]和PHP端:
elseif ($_REQUEST["oper"] == "del") {
$deleteSQL = sprintf("delete from snapper.catalogue where `catalogue`.`ID` = %s",
GetSQLValueString($_REQUEST['ID'], "int")
);
$Result = mysqli_query($GLOBALS["___mysqli_ston"],$deleteSQL) or die($error = mysqli_error($GLOBALS["___mysqli_ston"]));
}其中$_REQUEST['ID']不会传递给$_REQUEST["oper"] == "del",但是会传递给$_REQUEST["oper"] == "edit"
编辑转储:
_REQUEST - 2015-11-25 12:59:53:
Array
(
[Catalogue] => test523
[Artist] => STEPHANE GRAPPELLI
[Title] => kkk1651564
[UKDP] => 5.50
[Release_Date] => 25 Nov 15
[Ppoint] => 1
[Label] => 2
[Format] => 33
[Genre] => 27
[UPCEAN] => 636551052375
[AlbumCLineYear] => 0
[AlbumCLineInfo] =>
[AlbumPLineYear] => 0
[AlbumPLineInfo] =>
[Credits] =>
[Artist_Sort] =>
[Active] => 1
[Deleted] => 1
[id] => 1951
[copyID] =>
[oper] => edit
)DEL转储:
_REQUEST - 2015-11-25 13:00:49:
Array
(
[oper] => del
[id] => 4
)其中,[id]是网格中的行号,而不是数据库中的ID。为什么?
发布于 2015-11-25 20:35:12
如果你想在编辑/删除过程中发布的数据中id参数的名称是ID而不是id,你可能应该添加jqGrid的prmNames: { id: "ID" }选项?顺便说一句,您可以使用选项从colModel中删除不需要的隐藏ID列。
如果您确实需要保存隐藏列ID,且需要jqGrid将id和ID发送到服务器,那么您应该将editrules: { edithidden: true }, hidedlg: true属性添加到ID列的定义中。参见the old answer。
https://stackoverflow.com/questions/33916131
复制相似问题