c# - Is it possible to place Edit and Delete buttons in jQuery DataTables? -


i beginner using jquery datatable, , trying place edit , delete buttons in jquery datatable dynamic databinding in bootstrap in below image:

enter image description here

but error message:

enter image description here

controller action

    public class phonenumber     {         public string number { get; set; }         public string description { get; set; }         public string action { get; set; }     }      public actionresult loadphonenumbers()     {         var phonenumbers = new list<phonenumber>(new[]          {             new phonenumber { number = "555 123 4567", description = "george",action="" },             new phonenumber { number = "555 765 4321", description = "kevin" ,action="" },             new phonenumber { number = "555 555 4781", description = "sam",action=""  }         });          return json(new         {             aadata = phonenumbers.select(x => new[] { x.number, x.description })         }, jsonrequestbehavior.allowget);     } 

html

 <table id="tbladminusers" class="table table-striped table-bordered table-hover table-highlight table-checkable"                              data-info="true"                             data-search="true"                             data-paginate="true">                             <thead>                                 <tr>                                                                            <th>number</th>                                     <th>description</th>                                     <th>action</th>                                 </tr>                             </thead>                             <tbody>                             </tbody>                         </table> 

script

$(function () {      $("#tbladminusers").datatable({         bprocessing: true,         sajaxsource: '@url.action("loadphonenumbers", "admin")',         aocolumns: [              { mdata: "number" },              { mdata: "description" },              {                  mdata: "action",                  bsortable: false,                  mrender: function (o) { return '<i class="ui-tooltip fa fa-pencil" style="font-size: 22px;" data-original-title="edit"></i><i class="ui-tooltip fa fa-trash-o" style="font-size: 22px;" data-original-title="delete"></i>'; }              }         ]     }); }); 

please help.

i remove mdata attribute in aocolumns property

in datatable script.

$(function () {  $("#tbladminusers").datatable({     bprocessing: true,     sajaxsource: '@url.action("loadphonenumbers", "admin")',     aocolumns: [          { bsortable: false, },          { bsortable: false, },          {              bsortable: false,              mrender: function (o) { return '<i class="ui-tooltip fa fa-pencil" style="font-size: 22px;" data-original-title="edit"></i><i class="ui-tooltip fa fa-trash-o" style="font-size: 22px;" data-original-title="delete"></i>'; }          }     ] });}); 

Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -