用jquery easyui datagrid
$(function(){
product = $('#product').datagrid({
nowrap:false,
striped:true,
url:'listProduct.action',
sortName: 'pn',
sortOrder: 'desc',
idField:'pn',frozenColumns:[[ {field:'ck',checkbox:true}, ]], columns:[[ {field:'pn',title:'P/N',width:100,align:'center'}, {field:'description',title:'Description',width:120,align:'center'}, {field:'type',title:'Type',width:100,align:'center'}, {field:'brand',title:'Brand',width:60,align:'center'}, {field:'pack',title:'Package',width:60,align:'center'}, {field:'unit',title:'Unit',width:60,align:'center'}, {field:'unitCost',title:'Unit Cost',width:60,align:'right'}, {field:'sell',title:'Sell',width:60,align:'center'}, {field:'quantity',title:'Quantity',width:60,align:'center'}, {field:'dateCode',title:'Date Code',width:60,align:'center'}, ]], pagination:true, toolbar:[{ text:'Add', iconCls:'icon-add', handler:function(){ alert('add') } },'-',{ text:'Edit', iconCls:'icon-edit', handler:function(){ alert('edit') } },'-',{ text:'Delete', iconCls:'icon-remove', handler:function(){ delRows(product); } }] }); });
function delRows(table) {
var arr = getSelectedRows(table);
if (arr.length > 0) {
$.messager.confirm('Prompt', 'Are you sure to delete the selected record(s)', function (data) {
if (data) {
$.ajax({
url: 'delProduct',
type: 'get',
dataType: 'json',
data: {"id":"[{'id':3},{'id':5}]"},
// timeout: 1000,
error: function () {
$.messager.alert('Error', 'Delete Failure!', 'error');
},
success: function (data) {
if (data.success) {
grid.datagrid('reload');
grid.datagrid('clearSelections');
} else {
$.messager.alert('Error', data.msg, 'error');
}
}
});
}
});
} else {
$.messager.show({
title: 'Wraning',
msg: 'Please select the record you want to delete!'
});
}function getSelectedRows(table) {
var ids = [];
var rows = table.datagrid('getSelections');
for (var i = 0; i < rows.length; i++) {
ids.push(rows[i].id);
}
alert(ids.join('\n'));
return ids;
}
现在主要是data的数据,应该怎么样得到,多选的
现在写的红色部分是测试用的,主要是想传数组
对jquery不大熟悉,请大家指教
问题补充
嗯,这个是我加多了,删除了,谢谢
我就是想在前台用户选择了 多行数据(通过checkbox),然后我要在后台把这些删除,现在问题是不知道怎么样把这些选择的id传到后台