【发布时间】:2015-11-01 19:08:09
【问题描述】:
我需要我的 ro 基于两个 ID,Userid 和 certID。添加和更新时它工作正常,但是删除时我需要这两个 ID 来删除我在数据库中的记录,但所有来自 POST 数据的都是“id”和“oper”,我需要将额外的 certId 添加到发布数据。这是我的代码:
<!DOCTYPE HTML>
<html>
<head>
<title>jQGrid PHP inline Editing Tutorial</title>
<link type="text/css" rel="stylesheet" href="plugins/jquery-ui/jquery-ui.min.css">
<!--<link rel='stylesheet' href='plugins/jqGrid/css/ui.jqgrid.css'/>-->
<link type="text/css" rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" media="screen" href="plugins/jqGrid/css/ui.jqgrid-bootstrap.css" />
<script type="text/ecmascript" src="plugins/jquery/jquery-2.1.0.min.js"></script>
<script type="text/ecmascript" src='plugins/jqGrid/js/i18n/grid.locale-en.js'></script>
<script type="text/ecmascript" src='plugins/jqGrid/js/jquery.jqGrid.min.js'></script>
<script type="text/ecmascript" src="plugins/bootstrap-datepicker/js/bootstrap-datepicker.js"></script>
<script type="text/ecmascript" src="plugins/bootstrap-typehead/js/bootstrap3-typeahead.min.js"></script>
<link rel="stylesheet" type="text/css" media="screen" href="plugins/bootstrap-datepicker/css/bootstrap-datepicker.css" />
<meta charset="utf-8" />
<script>
$.jgrid.defaults.width = 780;
$.jgrid.defaults.responsive = true;
$.jgrid.defaults.styleUI = 'Bootstrap';
</script>
</head>
<body>
<div style="margin-left:20px;">
<table id="jqGrid"></table>
<div id="jqGridPager"></div>
</div>
<script type="text/javascript">
$(document).ready(function () {
$("#jqGrid").jqGrid({
url: 'getUserCertList.php',
editurl: 'UserCertUpdate.php',
mtype: "GET",
datatype: "json",
page: 1,
colModel: [
{ label: 'userID', name: 'id', editable: false, editrules: { edithidden: true }, hidden: true, width: 40, align: 'left' },
{ label: 'certificationid', name: 'certificationid', key: true, editable: false, editrules: { edithidden: true }, hidden: true, width: 40, align: 'left' },
{
label: 'Certification',
name: 'certid',
width: 200,
editable: true,
edittype: "select",
editrules : { required: true},
editoptions : {dataUrl: "getCertList.php"}
},
{
label : 'Date Certified',
name : 'dateCertified',
width : 80,
align : 'center',
editable : true,
sortable : true,
sorttype : 'date',
edittype : "text",
editrules : { required: true},
editoptions : {
// dataInit is the client-side event that fires upon initializing the toolbar search field for a column
// use it to place a third party control to customize the toolbar
dataInit: function (element) {
$(element).datepicker({
autoclose: true,
format: 'yyyy-mm-dd',
orientation : 'auto bottom'
});
}
}
},
{
label : 'Verified',
name : 'verified',
width : 40,
align : 'center',
sorttype : "number",
editable : false,
edittype : "checkbox",
editoptions : { value: "True:False" },
formatter : "checkbox", formatoptions: { disabled: true }
},
],
loadonce : true,
//onSelectRow: editRow, // the javascript function to call on row click. will ues to to put the row in edit mode
viewrecords: true,
height: 300,
rowNum: 20,
rownumbers: true, // show row numbers
rownumWidth: 35, // the width of the row numbers columns
pager: "#jqGridPager"
});
$('#jqGrid').navGrid("#jqGridPager", {edit: false, add: false, del: true, refresh: true, view: true, search:false},
{delData: {
name: function() {
var cert_id = $('#jqGrid').jqGrid('getGridParam', 'selrow');
var value = $('#jqGrid').jqGrid('getCell', cert_id, 'colName');
return value;
}
}
});
$('#jqGrid').inlineNav('#jqGridPager',{edit: false,add: true,del: true,cancel: true,
editParams: {keys: true,},
addParams: {keys: true},
});
});
</script>
</body>
</html>
【问题讨论】:
-
id在从getUserCertList.php返回的数据中使用什么(在填充网格期间)?您将key: true属性用于certificationid列。因此我可以假设certificationidanong 在服务器端污染了已删除的项目。你能得到userID有certificationid吗?