JQuery DataTables with ASP.Net MVC 4 with Custom Buttons -
i want use jquery datatables @ mvc 4 project grid based operations , general listing.
after search found jquery datatables , decided use it. @ first everythings seems when came add custom row buttons details, edit , delete problems started.
in conventional way adding button row adding code relevant <td> </td>
but datatables quite different, got below sample code here https://stackoverflow.com/a/9774102/423699
"aocolumndefs" : [ { "atargets": [0], "fncreatedcell" : function(ntd, sdata, odata, irow, icol){ var b = $('<button style="margin: 0">edit</button>'); b.button(); b.on('click',function(){ document.location.href = odata[0]; return false; }); $(ntd).empty(); $(ntd).prepend(b); } },
as mentions have 3 buttons , screens have optional buttons , appear after if-else conditions. until datatables using html.actionlink , css things show buttons; after using datatables becomes hard put buttons.
so think may wrong , can figure out.
i don't think click events added when apending element. suggest adding click event after button prepended.
"aocolumndefs" : [ { "atargets": [0], "fncreatedcell" : function(ntd, sdata, odata, irow, icol){ $(ntd) .empty()//empty .prepend('<button style="margin: 0">edit</button>')// prepend button td .filter("button")// filter results button element .button()// add jquery button effects .on('click',function(){// attach click event "filtered" button document.location.href = odata[0]; return false; }); } },
Comments
Post a Comment