升级至jqGrid 5.0.1 DELETE在EDIT仍然有效的情况下停止工作


Upgrade to jqGrid 5.0.1 DELETE stop working while EDIT still works

这是我的网格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。为什么?

如果您希望在编辑/删除期间发布的数据中id参数的名称为ID而不是id,那么您可能应该添加jqGrid的prmNames: { id: "ID" }选项?另外,使用该选项可以从colModel中删除不需要的隐藏ID列。

如果您确实需要保留隐藏列ID,并且需要jqGrid将idID都发送到服务器,那么您应该将editrules: { edithidden: true }, hidedlg: true属性添加到ID列的定义中。看看老答案。