我有一个 Jqgrid 表,其中有列'ord'
或顺序。我有更新按钮,单击该按钮应rows->column 'ord'
使用新订单值更新所有内容,即var neworder = {"Banana": 1,"Orange": 2,"Apple": 3,"Mango": 4};
注意:
var neworder = {"Banana": 1,"Orange": 2,"Apple": 3,"Mango": 4};
不会有重量和数量等其他信息;只是新的订单值。
HTML:
<button id="update">Update</button>
<table id="grid"></table>
JSFIDDLE:http: //jsfiddle.net/bababalcksheep/Bpk3E/
JS:
var data = [
[1,"Apple", "10", "2.3kg"],
[2,"Orange", "25", "3kg"],
[3,"Banana", "6", "1kg"],
[4,"Mango", "50", "10kg"]
];
$("#grid").jqGrid({
datatype: "local",
height: 250,
colNames: ['Ord','Fruit', 'Quantity', 'Weight'],
colModel: [{name: 'order',width: 10},{name: 'fruit',width: 50},{name: 'quantity',width: 20},{name: 'weight',width: 20}],
rownumbers: false,
autowidth: true,
caption: "Stack order"
});
// How to update col 'Ord' for all rows and trigger sort for that column
$( "#update" ).click(function() {
var neworder = {"Banana": 1,"Orange": 2,"Apple": 3,"Mango": 4};
});