Click here to Skip to main content
15,879,348 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hi
i need to do a batch action of delete in my data-table . before doing anything i need a check box on column one of every row . so when i check multiple , user can delete those rows on button click.

Any links or suggestions are appreciated

Regards
Posted

1 solution

Using mRender

JavaScript
$(document).ready(function () {
           var oTable = $('#example').dataTable({
               "aoColumnDefs": [{
                   "aTargets": [0],
                   //"mData": "download_link",
                   "mRender": function (data, type, full) {
                       if (data == "Gecko") {
                           return '<a href="' + data + '">' + data + ' Download Gecko</a>';
                       } else {
                           return '<a href="' + data + '">' + data + ' Download</a>';
                       }
                   }
               }, {
                   "aTargets": [1],
                   //"mData": "download_link",
                   "mRender": function (data, type, full) {
                       if (data == "1") {
                           return '<input type=\"checkbox\" checked value="' + data + '">';
                       } else {
                           return '<input type=\"checkbox\" value="' + data + '">';
                       }
                   }
               }, {
                   "aTargets": [2],
                   //"mData": "download_link",
                   "mRender": function (data, type, full) {
                       if (data == "1") {
                           return '<input type=\"checkbox\" checked value="' + data + '">';
                       } else {
                           return '<input type=\"checkbox\" value="' + data + '">';
                       }
                   }
               }, {
                   "aTargets": [3],
                   //"mData": "download_link",
                   "mRender": function (data, type, full) {
                       if (data == "1") {
                           return '<input type=\"checkbox\" checked value="' + data + '">';
                       } else {
                           return '<input type=\"checkbox\" value="' + data + '">';
                       }
                   }
               }, {
                   "aTargets": [4],
                   //"mData": "download_link",
                   "mRender": function (data, type, full) {
                       if (data == "1") {
                           return '<input type=\"checkbox\" checked value="' + data + '">';
                       } else {
                           return '<input type=\"checkbox\" value="' + data + '">';
                       }
                   }
               }

               ],
               "bFilter": false,
               "sScrollY": "500px",
               "bPaginate": false,
               "bProcessing": true,
               "sAjaxSource": "sources/sample.json"
           });


       });
 
Share this answer
 
Comments
sunil gutta 1-May-14 14:12pm    
He he to be frank i am just going through that question in stack-overflow . i am not sure i can do this just because you know i am having code with "aoColumns": [
{
"sName": "Lead_Id"

},
{
"sName": "LeadName"
},
{ "sName": "ContactName" },
{ "sName": "CompanyName" },
] ..what to do ?
Guruprasad.K.Basavaraju 1-May-14 16:16pm    
Ok, I never used this one. Let me set up a sample project and try this out sometime today. Hope you can wait on this one.
sunil gutta 2-May-14 2:18am    
i will wait no matter what . please ping me when you find some way :) cheers
sunil gutta 2-May-14 15:20pm    
me to trying on the same thing any progress please ping me . check-box deletion in grid will be easy but datatable uff need to work deeper
sunil gutta 3-May-14 6:29am    
mate find this links it will be helpful fpr progress i got checkbox at column one . multiple selection and deleting remaining .
http://forums.asp.net/t/1959180.aspx?0x800a01b6+JavaScript+runtime+error+Object+doesn+t+support+property+or+method+dialog+
and
https://editor.datatables.net/examples/inline-editing/simple .

Thank you . Let me know if you find any workaround

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900