Selecting row after sorting, does not send data.

Selecting row after sorting, does not send data.

StpdudeStpdude Posts: 30Questions: 0Answers: 0
edited February 2013 in General
Hey guys, got a question. So my table now correctly displays, allows full CRUD functionality. and sorts. Problem I've just discovered is if i sort the rows (by anything OTHER then the ID column i should add) , select some, and then try to delete them, the program does NOT capture their data and send it. IE: i sort by name, select a row and hit delete and it sends:
[code]tableData=[/code]
and throws an error [code] SEVERE: Servlet.service() for servlet [dispatcher] in context with path [/dfvisualizer] threw exception [Request processing failed; nested exception is java.lang.NumberFormatException: For input string: ""] with root cause
java.lang.NumberFormatException: For input string: "" [/code]

but if its done correctly it should pass:
[code]tableData=400[/code] with the 400 being the ID of the row i selected.

here is my page cmsgroup.jsp:
[code]

$(document).ready(function(){
var oTable = $('#dataTable').dataTable({
"bProcessing": true,
"bJQueryUI": true,
"bPaginate": true,
"sPaginationType": "full_numbers",
"iDisplayLength": 10,
"aLengthMenu": [[10, 25, 50, 100, -1], [10, 25, 50, 100, "All"]],
"sDom": 'pT<>rt',
"sAjaxSource": 'dataTable/getCmsGroupData',
"aoColumns": [
{ "mData": "id", "sTitle": "ID", "fnRender": function (oObj) {
return '' + oObj.aData["id"] + '';
}},
{ "mData": "version", "sTitle":"Version" },
{ "mData": "name", "sTitle": "Name" },
{ "mData": "description", "sTitle": "Description"},
{ "mData": "notes", "sTitle": "Notes"},
],
"aaSorting": [[ 0, "asc" ]],
"oTableTools": {
"sRowSelect": "multi",
"aButtons": [
{
"sExtends": "text",
"sButtonText": "Delete",
"fnClick": function(nButton, oConfig, nRow){
if (confirm('Are you sure want to delete this record?')) {
var list = $('tr.DTTT_selected > td.sorting_1 > a').map(function () {
return this.text;
}).get().join(",");
$.ajax({
type: "POST",
url: "dataTable/delete/cmsGroup",
data: 'tableData='+ list,
success: function(result) {
if(result.resultcode==1){
alert("Failed to delete entry id(s): "+list+" because: \n"+result.errorMessage);
alert(result.failed+" deletes failed");
//location.reload();
}
else{
alert("Entry Deleted");
$('tr.DTTT_selected').remove();
alert(result.failed+" deletes failed");
}
},
error: function(xhr, status, error) {
alert("An error occured: \n" + error);
}
} );
}}},
"select_all",
"select_none",
{
"sExtends": "text",
"sButtonText": "Create New Entry",
"fnClick": function ( nButton, oConfig, oFlash ) {
window.location = "cmsgroup_add";
}}]}});
} );




CMS Group












[/code]

and my controller which handles the delete like so:
[code]
@RequestMapping(value= "/dataTable/delete/cmsGroup", method = RequestMethod.POST)
@ResponseBody
public ErrorController deleteDataTableCmsGroup(HttpServletRequest request, HttpServletResponse response) throws JsonParseException, IOException{
ErrorController errController = new ErrorController();
System.out.println("in dataTable/delete/CmsGroup...");
String toDelete = request.getParameter("tableData");
String ids[] = toDelete.split(",");
int failed = 0;
System.out.println("ids length is "+ids.length);
if (ids.length>0){
for (String id: ids){
int input = Integer.parseInt(id.trim());
try{
cmsGroupDao.deletebyId(input);
}
catch(DataIntegrityViolationException e){
errController.setResultcode(1);
errController.setErrorMessage(e.getMessage());
failed = failed+1;
errController.setFailed(failed);
}
catch(Exception e){
System.out.println(e);
}
}
}
else if (ids.length==0){
System.out.println("size 0");
}
return errController;
}[/code]

anyone got any clues?

Replies

This discussion has been closed.