0
내가 TEH followng 그리드체크 된 모든 행의 열 값을 얻으려면 어떻게해야합니까?
여기을 만든이 코드입니다 : 내가 버튼을 보내기를 클릭 할 때
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/themes/le-frog/jquery-ui.min.css" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/free-jqgrid/4.13.6/css/ui.jqgrid.min.css" />
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" />
<style>
</style>
</head>
<body>
<table id="list"></table>
<div>
<input type="button" id="btn" value="send" />
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
<script>
$.jgrid = $.jgrid || {};
$.jgrid.no_legacy_api = true;
$.jgrid.useJSON = true;
</script>
<script src="https://rawgit.com/free-jqgrid/jqGrid/master/js/jquery.jqgrid.src.js"></script>
<script type="text/javascript">
$(document).ready(function(){
var data =
[
{id:'1', name:'john dillon', city:'london', active:false},
{id:'2', name:'marcus maxi', city:'chicago', active:false},
{id:'3', name:'fedro james', city:'new york', active:false},
{id:'4', name:'alias hue', city:'georgia', active:false},
{id:'5', name:'greg finto', city:'st louis', active:false}
];
jQuery("#list").jqGrid({
data:data,
colNames: ['id','Name','City', 'active'],
colModel: [
{name: 'id', index: 'id', width: 220, sorttype:"int", hidden:false },
{name: 'name', index: 'name', width: 220 },
{name: 'city', index: 'city', width: 220 },
{name: 'active', index: 'active', width: 60, align: 'center',
edittype: 'checkbox',
editoptions: {value: 'Yes:No', defaultValue: 'Yes'},
formatoptions: { disabled: false},
formatter:function(cellvalue, options, rowObject)
{
if(rowObject.active===true)
{
return '<input type="checkbox" id="cbPassed-'+ rowObject.id +'" checked/>';
}
else
{
return '<input type="checkbox" id="cbPassed-'+rowObject.id+ '" />';
}
}
}
],
beforeSelectRow: function (rowid, e) {
var $self = $(this),
iCol = $.jgrid.getCellIndex($(e.target).closest("td")[0]),
cm = $self.jqGrid("getGridParam", "colModel"),
localData = $self.jqGrid("getLocalRow", rowid);
if (cm[iCol].name === "active") {
localData.active = $(e.target).is(":checked");
}
return true;
},
threeStateSort:true,
autoencode: true,
sortname: "id",
viewrecords: true,
sortorder: "asc",
shrinkToFit: false,
caption:'sampples'
//width:'400px'
});
$('#btn').click(function(){
var myGrid = $('#list');
var i,
selRowIds = myGrid.jqGrid("getGridParam", "selarrrow"),
n,
rowData;
console.log(JSON.stringify(selRowIds));
for (i = 0, n = selRowIds.length; i < n; i++)
{
rowData = myGrid.jqGrid("getLocalRow", selRowIds[i]);
console.log('selected row data:'+ JSON.stringify(rowData));
}
var grid = $('#list');
var ids = grid.jqGrid('getGridParam', 'selarrrow');
console.log(JSON.stringify(ids));
})
})
</script>
</body>
</html>
TEH 순간, 그것은 단지의 id
열 값을 가져옵니다 마지막으로 확인 된 행 그러나 모든 검사 된 행의 모든 name
열 값을 얻으려면 어떻게해야합니까?
감사합니다. Oleg, 체크 박스 선택 문제가 수정되었습니다.) –
@ Dore.Ad : 오신 것을 환영합니다! – Oleg