Javascript JQGrid:通过 post 在 JQGrid 中获取多个选中的行值
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10121174/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
JQGrid: get multiple checked row values in JQGrid by post
提问by Sridhar
I have one JQGrid in my php file and I have placed inside one form . On submitting form, i just want the checked value from the JQGrid.
我的 php 文件中有一个 JQGrid 并且我已经放置在一个表单中。在提交表单时,我只想要来自 JQGrid 的选中值。
<script type="text/javascript">
$(function() {
$("#list1").jqGrid({
url:'revMemberJson.php',
datatype: 'json',
mtype: 'GET',
loadonce: true,
// jsonReader: { repeatitems: false },
colNames:['Name','Mobile'],
colModel :[
{name:'name', index:'name',width: 100,searchoptions: { sopt: ['eq', 'ne','cn']}},
{name:'mobile', index:'mobile',search: false,width: 120}
],
pager: '#pager',
rowNum: 5,
rowList:[5,20,30],
rownumbers: true,
multiselect:true,
sortname: 'id',
sortorder: 'desc',
viewrecords: true,
height: 'auto',
width: 420,
shrinkToFit: false,
gridview: true,
caption: 'Members'
});
jQuery("#list1").jqGrid('navGrid','#pager',{edit:false,add:false,del:false});
});
var myGrid = $('#list1'),
selRowId = myGrid.jqGrid ('getGridParam', 'selrow'),
celValue = myGrid.jqGrid ('getCell', selRowId, 'mobile');
</script>
And I have used the following code to get the checked value , But All stuff are made in java script. But I have to get the values for updating the database. So i need to get the value by post.
我已经使用以下代码来获取选中的值,但是所有的东西都是在 java 脚本中制作的。但是我必须获取更新数据库的值。所以我需要通过邮寄获得价值。
Please provide me the methods..
请给我方法..
回答by Oleg
You should use
你应该使用
var selRowIds = myGrid.jqGrid ('getGridParam', 'selarrrow');
insteda of
代替
var selRowId = myGrid.jqGrid ('getGridParam', 'selrow');
to get the array with ids of selected rows. You can use JSON.stringify(selRowIds)or selRowIds.join(',')to convert array in the form which you can easy send to the server.
获取具有所选行 ID 的数组。您可以使用JSON.stringify(selRowIds)或selRowIds.join(',')以可以轻松发送到服务器的形式转换数组。
I think that you can find some additional information in the answer(see the demo).

