我的数据表中总共有276行,我可以使用JQuery 1.11.3从我的数据库中检索这些行。当我向该数据表添加新行时,它会抛出此警告消息:
数据表警告:表格id = featuresList-请求的未知参数' id'第276行。
" ID"是我的数据库列的名称。当我在其他标签中打开请求的链接时,它返回了我的行ID。我正在使用jQuery 1.11.3。我能够将此数据插入数据库,但无法将此新行添加到数据表中。
Javascript
$(document).ready(function() {
$('#featuresList').dataTable({
"bProcessing": true,
"bServerSide": false,
"sort": "position",
"bStateSave": false,
"iDisplayLength": 10,
"iDisplayStart": 0,
"fnDrawCallback": function() {
//Get page numer on client. Please note: number start from 0 So
//for the first page you will see 0 second page 1 third page 2...
//Un-comment below alert to see page number
//alert("Current page number: "+this.fnPagingInfo().iPage);
},
"sAjaxSource": "/maintainFeatures/maintainFeaturesData",
aoColumns: [
{
"mData": "id",
"bVisible": false
},
{
"mData": "dataId"
},
{
"mData": "description"
},
{
"mData": null,
"bSearchable": false,
"bSortable": false,
"mRender": function(data, type, full) {
var id1 = full.id;
return "<a class='table-action-deletelink' href='javascript:alert(" + id1 + ");'>Edit</a>";
}
},
{
"mData": null,
//"sName": "Id",
"bSearchable": false,
"bSortable": false,
"mRender": function(data, type, full) {
//console.dir( oObj.aData[0] ) ;
var id1 = full.id;
return "<a class='table-action-deletelink' href='/maintainFeatures/delete?id=" + full.id + "'>Delete</a>";
}
}
]
})
.makeEditable({
sUpdateURL: "/maintainFeatures/update",
sAddURL: "/maintainFeatures/AddData",
sAddHttpMethod: "GET", //Used only on google.code live example because google.code server do not support POST request
sDeleteURL: "/maintainFeatures/delete",
sDeleteHttpMethod: "GET", //Used only on google.code live example because google.code server do not support POST request
"aoColumns": [
{
cssclass: "required"
},
null, //null for read-only columns
{
indicator: 'Saving...',
tooltip: 'Click to select town',
loadtext: 'loading...',
type: 'select',
onblur: 'submit',
data: '{"London":"London","Liverpool":"Liverpool","Portsmouth": "Portsmouth","Edinburgh":"Edinburgh", "Blackburn":"Blackburn","Kent":"Kent","Essex":"Essex","Oxon":"Oxon","Lothian":"Lothian", "West Sussex":"West Sussex","Lanarkshire":"Lanarkshire", "Birmingham":"Birmingham","East Sussex":"East Sussex","Surrey":"Surrey"}'
}
]
});
});
HTML
<table id="featuresList" class="table table-striped table-bordered" cellspacing="0" width="100%">
<thead>
<tr>
<th>Id</th>
<th>Data_ID</th>
<th>Description</th>
<th>Edit</th>
<th>Delete</th>
</tr>
</thead>
</table>
<button id="btnAddNewRow" value="Ok">Add new record</button>
<form id="formAddNewRow" action="#" title="Add new feature">
<input type="hidden" id="id" name="id" value="-1" rel="0" />
<label for="name">DataID</label><input type="text" name="dataId" id="dataId" rel="1" />
<br />
<label for="name">Description</label><input type="text" name="description" id="description" rel="2"/>
<br />
</form>
Java控制器类
@RequestMapping(value="/AddData")
public @ResponseBody Long add(HttpServletRequest request, Model model)
{
String dataid =(request.getParameter("dataId"));
String desc =(request.getParameter("description"));
System.out.println(dataid+";"+desc);
Feature f= new Feature();
f.setDataId(dataid);
f.setDescription(desc);
f = featureService.create(f);
return f.getId();
}