Monday, January 28, 2013

JQuery DataTables update cells

1) on client side,


var oTable2 = $('#example').dataTable().makeEditable({
sUpdateURL : "updateUser.do",
"aoColumns" : [ {}, null, null, null, null ]   // null means this column is not allowed to edit
});

2) on servlet side,


@RequestMapping(value = "/updateUser.do", produces = "application/json")
public @ResponseBody
String updateUser(@RequestParam String value, @RequestParam String id) {
String method = "updateUser";
info(method, "recieved updating record:[value]=" + value + ",[id]="
+ id);
                // update data in db
                 ...............
// if success, return the exact the same value back
// return value;
//if false, return error msg directly
return "failed to update";
}

3) actual result if failed to update










as to how to set id to each row in the table, refer to http://wangxiangblog.blogspot.sg/2013/01/jquery-datatables-add-id-attribute-to.html

1 comment:

  1. I think you can have moderate success by copying something else, but if you really want to knock it out of the park, you have to do something different and take chances. See the link below for more info.


    #copying
    www.matreyastudios.com

    ReplyDelete