我使用jqGrid,我添加一个复选框列,我想能够获得检查行,所以我可以调用服务器与他们...
I'm using jqGrid, and I add a checkbox column, I want to be able to get checked rows so I can call the server with them...
My jqGrid Code:
My jqGrid Code:
<script type="text/javascript"> $(function () { $("#UsersGrid").jqGrid({ url: "Handler.ashx", datatype: 'json', height: '100%', width: '500', colNames: [' ', 'ref#', 'Module', 'TT#', 'AssignedOn', 'TrialNo'], colModel: [ { name: ' ', index: 'ChkBox', width: 16, sortable: false, editable: true, formatter: "checkbox", formatoptions: { disabled: false }, editable: true, edittype: "checkbox" }, { name: 'ref#', width: 50, sortable: true }, { name: 'Module', width: 50, sortable: true }, { name: 'TT#', width: 110, sortable: true }, { name: 'AssignedOn', width: 110, sortable: true }, { name: 'TrialNo', width: 50, sortable: true } ], rowNum: 10, rowList: [10, 20, 30], pager: '#UsersGridPager', sortname: ' ', viewrecords: true, sortorder: 'asc' //caption: "Cases" }); $("#UsersGrid").jqGrid('navGrid', '#UsersGridPager', { edit: false, add: false, del: false }); </script>感谢在进阶...
推荐答案你应该更好的multiselect:true,因为我可以看到你正在实施复选框是选择多行。
You should better you multiselect:true, because the functionality i can see you are implementing with check boxes is to select multiple rows.
这里是如何将工作u。 1.在jqgrid参数中进行multiselect:true。
here's how it will work for u. 1. Make multiselect:true in jqgrid Parameters.
button type =buttonvalue =submitid =clickMe>提交/按钮> //正确启动和关闭标签。 >
button type="button" value="submit" id="clickMe" >Submit /button> //start and close the tags properly.
$('#clickMe')click(function(){ var selRowIds = $('#grid')。jqGrid('getGridParam' ,'selarrrow');
$('#clickMe').click(function(){ var selRowIds = $('#grid').jqGrid('getGridParam', 'selarrrow');
if(selRowIds.length>0) { for( var i=0;i<selRowIds.length;i++){ var ref#=getCellValue(selRowIds[i],'ref#'); var Module=getCellValue(selRowIds[i],'Module'); var TT#=getCellValue(selRowIds[i],'TT#'); var AssignedOn=getCellValue(selRowIds[i],'AssignedOn'); var TrialNo=getCellValue(selRowIds[i],'TrialNo'); $.ajax({ type: 'POST', url: '@Url.Action("editMe")', contentType: 'application/json; charset=utf-8', data:JSON.stringify({ref#: ref#, Module:Module,TT#:TT#,AssignedOn:AssignedOn,TrialNo:TrialNo}), dataType: "json", success:function(){ $('#grid').trigger("reloadGrid"); }, error: function () { alert("error"); } }); } } });且您的控制器应如下所示:
and your controller should look like this
public ActionResult editMe(string ref#, string Module, string TT#, string AssignedOn, string TrialNo) { }我假设你有所有的列的dataType为字符串,它们都是可编辑的:true(你可以使用colModal only模块,AppliedOn是可编辑的true,所以你可以在按钮点击只能得到这两个值,根据你的需要你可以改变代码。
I'm assuming you have dataType for all the columns as string and they all are editable:true(you can mention this with colModal. So if only Module, AppliedOn is editable true, so you can get only these two values in button click. depending upon your need you can change the code.
更多推荐
如何获取选中的行ID?
发布评论