DataTables- aoData is null when expanding details of a row -
i'm using drilldown datatable found here.
the datatable exists within accordion. user select category clicking it, expands out display datatable relevant category. function inittable called when user clicks category.
datatables doc says utilize code business relationship multiple datatables on page, can't work.
$(document).ready(function() { $('.datatable').datatable(); } );
what did rather utilize "#example", replaced "#" + category, 99% works. can click category, drill downwards see additional info on row, switch new category, same thing.
what doesn't work - if click category, either close category or go , go first - expanding row throws error "aodata" null or not object. next 3 images show i'm talking about. notice in 3rd image detail row doesn't display.
i can't insert images, i've posted them here show i'm talking about.
here's inittable function that's called create table. i'm using bdestroy destroy existing table before creating new one.
any help appreciated!
function inittable(category, facility) { if (gscategory == "") gscategory = category; else if (gscategory == category) gbtoggle = !gbtoggle; else gbtoggle = false; gscategory = category; if (gbtoggle == false) { gscategory = category; var select = document.forms[0].selfacility; var facility = select.options[select.selectedindex].value; document.body.style.cursor = 'wait'; var patjson = getjson(facility, category); var anopen = []; var simageurl = "../images/"; maketable(category); document.body.style.cursor = 'default'; var otable = $('#'+category).datatable( { "bprocessing": false, "bdestroy": true, "aadata": patjson, "bautowidth": false, "aocolumns": [ { "mdataprop": null, "sclass": "control center", "sdefaultcontent": '<img src="'+simageurl+'details_open.png'+'">', "swidth": "5%" }, { "mdataprop": "s_pat_name", "swidth": "30%" }, { "mdataprop": "s_age", "swidth": "15%"}, { "mdataprop": "s_fin", "swidth": "30%"}, { "mdataprop": "s_room_bed", "swidth": "20%" } ] } ); $('#'+category+' td.control').live( 'click', function () { var ntr = this.parentnode; var = $.inarray( ntr, anopen ); if ( === -1 ) { $('img', this).attr( 'src', simageurl+"details_close.png" ); var ndetailsrow = otable.fnopen( ntr, fnformatdetails(otable, ntr), 'details' ); $('div.innerdetails', ndetailsrow).slidedown(); anopen.push( ntr ); } else { $('img', this).attr( 'src', simageurl+"details_open.png" ); $('div.innerdetails', $(ntr).next()[0]).slideup( function () { otable.fnclose( ntr ); anopen.splice( i, 1 ); } ); } } ); } } function fnformatdetails( otable, ntr ) { var odata = otable.fngetdata( ntr ); var sout = '<div class="innerdetails">'+ '<table cellpadding="5" cellspacing="0" border="0" style="padding-left:50px;">'+ '<tr><td>trigger order:</td><td>'+odata.s_trigger_med+'</td></tr>'+ '<tr><td>allergies:</td><td>'+odata.s_allergies+'</td></tr>' '</table>'+ '</div>'; homecoming sout; }
jquery-datatables
No comments:
Post a Comment