The checkbox field created with add API method doesn't check the selected values got from the server[when clicked on
Edit button of editor]. Interestingly the checkbox field created using fields initialization option checks the selected values got from the server.
This works:
Below doesn't show check to selected values:
below is my trimmed json string:
Please note in the json string "usertype":"1|2" is the separated list of values to check. The checkboxs are checked [in Edit form of editor] when field is initialized using fields initialization option but when I use the second approach using add method of api the checkboxs are not shown checked in edit form.
http://editor.datatables.net/fields/#checkbox
Any pointers why the second approach doesn't work?
Regards,
Mathew
Edit button of editor]. Interestingly the checkbox field created using fields initialization option checks the selected values got from the server.
This works:
editor = new $.fn.dataTable.Editor( { "ajaxUrl": ".....", "domTable": "....", "idSrc": "id", "fields": [ .... .... { "label": "User type:", "name": "usertype", "type": "checkbox", "separator": "|", "ipOpts": [ { "label": "Student", "value": "1" }, { "label": "Proctor", "value": "2" } ] } ], .... ... });
Below doesn't show check to selected values:
editor = new $.fn.dataTable.Editor( { "ajaxUrl": ".....", "domTable": "....", "idSrc": "id", .... ... }); editor.on('onInitCreate', function () { fnUserScreenFields(); } editor.on('onInitEdit', function () { fnUserScreenFields(); } function fnUserScreenFields() { editor.add({ "label": "First name:", "name": "fname" }); editor.add({ "label": "Middle name:", "name": "mname" }); editor.add({ "label": "Last name:", "name": "lname" }); editor.add({ "label": "User type:", "name": "usertype", "type": "checkbox", "separator": "|", "ipOpts": [ { "label": "Student", "value": "1" }, { "label": "Proctor", "value": "2" } ] }); .... .... } var table = $('#userlist').dataTable( { .... });
below is my trimmed json string:
{"sEcho":1,"iTotalRecords":"13","iTotalDisplayRecords":"13","aaData":[{"id":"102674","fname":"xyz",...,"usertype":"1|2"}, ...
Please note in the json string "usertype":"1|2" is the separated list of values to check. The checkboxs are checked [in Edit form of editor] when field is initialized using fields initialization option but when I use the second approach using add method of api the checkboxs are not shown checked in edit form.
http://editor.datatables.net/fields/#checkbox
Any pointers why the second approach doesn't work?
Regards,
Mathew