jqgrid:多选值不工作
jqgrid : multiselect vales not working
我正在使用 Jqgrid 示例创建 table,我正在尝试获取所有选中行的值并使用 ajax.[=12 将选定的值传递给服务器=]
目前它没有得到选择的值,当我点击获取选择按钮时。
这里 link 到我的 fiddle
另外,是否可以在每一行中添加单选按钮,并且整个单选按钮只能被选中table。
/***********************/
$("#getSelected").click(function() {
var ids = $("#output").jqGrid('getGridParam', 'selarrrow');
if (ids.length > 0) {
var names = [];
for (var i = 0, il = ids.length; i < il; i++) {
var name = $("#output").jqGrid('getCell', ids[i], 'Symbol');
names.push(name);
}
//alert ("Names: " + names.join(", ") + "; ids: " + ids.join(", "));
$("#names").html(names.join(", "));
$("#dialog-confirm").dialog({
height: 280,
modal: true,
buttons: {
'Cancel': function() {
$(this).dialog('close');
},
'Confirm': function() {
alert("Confirm");
//alert ("Names: " + names.join(", ") + "; ids: " + ids.join(", "));
/*$.ajax({
type: "POST",
url: "/cpsb/unprocessedOrders.do",
data: { method: "releaseTowics",
orderNum: JSON.stringify(ids),
names: JSON.stringify(names)
},
dataType: "json"
success: function(msg){
alert(msg);
},
error: function(res, status, exeption) {
alert(res);
}
});*/
}
}
});
}
});
/***********************/
您似乎使用了 the old demo, which I created for the old answer 中的代码。该演示使用 jQuery UI 对话框。因此,为了让您以最小的更改进行演示,您应该包括 jquery-ui.min.js
和 div,它们将用作 jQuery 对话框,例如,
<div style="display:none;" id="dialog-confirm" title="Confirm">
<p>Are you sure want send this names:</p><p><span id="names"></span></p>
</div>
修改后的演示 https://jsfiddle.net/OlegKi/615qovew/112/ 有效。如果您愿意,当然可以将 jQuery UI 替换为 Bootstrap 对话框。
我在演示中将额外免费的 jqGrid 4.13.3 替换为当前免费的 jqGrid 1.14.0。我添加了 autoresizeOnLoad: true
选项和 autoResizing
的新 resetWidthOrg: true
属性 以使列的宽度与内容的宽度成比例地调整大小(有关更多详细信息,请参阅 the issue ).
我正在使用 Jqgrid 示例创建 table,我正在尝试获取所有选中行的值并使用 ajax.[=12 将选定的值传递给服务器=]
目前它没有得到选择的值,当我点击获取选择按钮时。
这里 link 到我的 fiddle
另外,是否可以在每一行中添加单选按钮,并且整个单选按钮只能被选中table。
/***********************/
$("#getSelected").click(function() {
var ids = $("#output").jqGrid('getGridParam', 'selarrrow');
if (ids.length > 0) {
var names = [];
for (var i = 0, il = ids.length; i < il; i++) {
var name = $("#output").jqGrid('getCell', ids[i], 'Symbol');
names.push(name);
}
//alert ("Names: " + names.join(", ") + "; ids: " + ids.join(", "));
$("#names").html(names.join(", "));
$("#dialog-confirm").dialog({
height: 280,
modal: true,
buttons: {
'Cancel': function() {
$(this).dialog('close');
},
'Confirm': function() {
alert("Confirm");
//alert ("Names: " + names.join(", ") + "; ids: " + ids.join(", "));
/*$.ajax({
type: "POST",
url: "/cpsb/unprocessedOrders.do",
data: { method: "releaseTowics",
orderNum: JSON.stringify(ids),
names: JSON.stringify(names)
},
dataType: "json"
success: function(msg){
alert(msg);
},
error: function(res, status, exeption) {
alert(res);
}
});*/
}
}
});
}
});
/***********************/
您似乎使用了 the old demo, which I created for the old answer 中的代码。该演示使用 jQuery UI 对话框。因此,为了让您以最小的更改进行演示,您应该包括 jquery-ui.min.js
和 div,它们将用作 jQuery 对话框,例如,
<div style="display:none;" id="dialog-confirm" title="Confirm">
<p>Are you sure want send this names:</p><p><span id="names"></span></p>
</div>
修改后的演示 https://jsfiddle.net/OlegKi/615qovew/112/ 有效。如果您愿意,当然可以将 jQuery UI 替换为 Bootstrap 对话框。
我在演示中将额外免费的 jqGrid 4.13.3 替换为当前免费的 jqGrid 1.14.0。我添加了 autoresizeOnLoad: true
选项和 autoResizing
的新 resetWidthOrg: true
属性 以使列的宽度与内容的宽度成比例地调整大小(有关更多详细信息,请参阅 the issue ).