我希望能够订阅可分类拖放操作期间引发的事件(3.6可排列行中的新增内容)为我需要将这些信息存回存储器。我已经试过了从http://www.trirand.com/jqgridwiki/doku.php?id=wiki:jquery_ui_methods#drag_and_drop_rows_between_grids onstop和onstart,但它似乎只适用于放置目标是另一个表。如何用行重新排序的适当事件初始化jqGrid(可排序)
谢谢 斯蒂芬
列:
var col_names = ['Qty', 'SFC', 'Item Nbr', 'Brand', 'Product', 'Catalog', 'Price', 'UOM', 'Case', 'Remarks', 'Wt.', 'Par', 'Purchased', 'ProductId', 'SortPriority'];
var col_model = [
{ name: 'Quantity', index: 'Quantity', width: 22, sorttype: "number", editable: true, edittype: 'text', editoptions: { size: 10, maxlength: 15} },
{ name: 'ProductAttributes', index: 'ProductAttributes', width: 50 },
{ name: 'ItemNum', index: 'ItemNum', width: 50, align: "right" },
{ name: 'BrandName', index: 'BrandName', width: 100 },
{ name: 'ProducName', index: 'ProducName', width: 150 },
{ name: 'Catalog', index: 'Catalog', width: 100 },
{ name: 'Price', index: 'Price', width: 40, sorttype: "number", align: "right" },
{ name: 'UOM', index: 'UOM', width: 30 },
{ name: 'CasePack', index: 'CasePack', width: 30 },
{ name: 'PackageRemarks', index: 'PackageRemarks', width: 80 },
{ name: 'AveWeight', index: 'AveWeight', width: 30, align: "right" },
{ name: 'Par', index: 'Par', width: 25, align: "right", editable: true, edittype: 'text', editoptions: { size: 15, maxlength: 15} },
{ name: 'LastPurchaseDate', index: 'LastPurchaseDate', width: 40, align: "right" },
{ name: 'ProductId', index: 'ProductId', hidden: true, key: true },
{ name: 'SortPriority', index: 'SortPriority', hidden: true }
];
网格:
favoriteGrid = $('#favoriteGrid');
favoriteGrid.jqGrid({
url: '/xxx/yyy/',
datatype: 'json',
ajaxGridOptions: { contentType: "application/json" },
jsonReader: {
id: "ProductId",
cell: "",
root: function (obj) { return obj.rows; },
page: function() { return 1; },
total: function() { return 1; },
records: function (obj) { return obj.rows.length; },
repeatitems: true
},
colNames: col_names,
colModel: col_model,
pager: $('#favoritePager'),
pginput: false,
rownumbers: true,
rownumWidth: 25,
rowNum: 1000,
autowidth: true,
height: '500px',
sortable: true, // enable column sorting
multiselect: true, // enable multiselct
gridview: true,
ignoreCase: true,
loadonce: true, // one ajax call per
loadui: 'block',
loadComplete: function() {
var gr = $('#favoriteGrid');
fixGridSize(gr);
},
onSelectRow: function (id) {
if (id && id !== lastSel) {
favoriteGrid.restoreRow(lastSel);
lastSel = id;
}
favoriteGrid.editRow(id, true);
},
onstop: function (event, ui) {
alert("onstop");
}
}).jqGrid('navGrid', '#favoritePager',
{ add: false, edit: false, del: false, search: true, refresh: false },
{},
{},
{},
{ multipleSearch: true, showQuery: false },
{}).jqGrid('sortableRows').jqGrid('gridDnD');
EDIT1:
从jqGrid的生成表中排序,所以我觉得这是在initializ之后使用这些jquery函数的问题通货膨胀。
$('#favoriteGrid').bind("sortstart", function (event, ui) {
alert("start");
});
$('#favoriteGrid').bind("sortstop", function (event, ui) {
alert("stop");
});
我不认为我描述了我一直在寻找correctly..sorry。 HTTP://www.trirand。com/blog/jqgrid/jqgrid.html> 3.6版新增功能>可排序行。谢谢,斯蒂芬 – 2012-01-31 23:46:51
@SPATEN:对不起,这是我的错误。我更新了'sortableRows'的答案。 – Oleg 2012-02-01 07:39:43