VO
List<String> status;
Controller
@RequestMapping(value="/ed/statusList",method = RequestMethod.POST)
public @ResponseBody Object statusList(HttpServletRequest request, HttpServletResponse response, CurriculumSearchExt ce) throws JsonGenerationException, JsonMappingException, IOException {
System.out.println(ce.getStatus());
...
}
javascript
$("input[name='status']:checkbox").on('click', function() {
var checkArr = [];
$("input[name='status']:checked").each(function() {
checkArr.push($(this).val());
});
console.log("checkArr:" + checkArr);
if(checkArr.length == 0) {
checkArr = [""];
}
...//some other parameters
formdata = {
...
"status" : checkArr
};
$("#gridlist").jqGrid("clearGridParam", true);
$("#gridlist").jqGrid('setGridParam', {
url : 'ed/statusList',
datatype : 'json',
mtype : 'post',
postData : formdata,
ajaxGridOptions : {
traditional : true,
complete : function(data) {
console.log('success');
}
}
}).trigger('reloadGrid');
});
HTML
<input type="checkbox" name="status" value="10">a
<input type="checkbox" name="status" value="20">b
<input type="checkbox" name="status" value="30">c
<input type="checkbox" name="status" value="50">d
<input type="checkbox" name="status" value="60">e
When I check 'a', then checkArr:10 is printed at chrome and [10] is printed at server.
I check 'b'('a','b' are checked), then checkArr:10, 20 is printed at chrome and [10, 20] is printed at server.
and lastly, here is the problem.
When I check 'b' again(only 'a' is checked), then checkArr:10 is printed at chrome and [10, 20] is printed at server.
If I check 'b' again and uncheck 'a'(only 'b' is checked), then checkArr:20 is printed at chrome and [20,20] is printed at server.
The list 'checkArr' is normally worked at javascript, but controller can`t receive the right things. I want 'checkArr' to go to controller just the way it is.
If you have other things you nead, please comment. Thanks for read.