我正在为数据表中的行中数据获取数据未定义

时间:2016-12-27 11:25:43

标签: javascript jquery datatables

从后端获取表格:

The table

  generateBatchTable: function (data) {
            //get table id from jquery
            for (var i=0; i< data.length; i++){
                batchElement.append(
                    '<tr id="batch'+data[i].batchId+'">' +
                        '<td></td>' +
                        '<td class="btdetails"><a>'+data[i].batchName+'</a></td>' +
                     /* '<td>'+data[i].validFrom+'</td>' +
                        '<td>'+data[i].validTo+'</td>' +
                        '<td>'+data[i].lunchexpenses+'</td>' +
                        '<td>'+data[i].miscellaneous+'</td>' +
                        '<td>'+data[i].travellingexpenses+'</td>' +
*/
                        /*'<td class="batchStatus" value='+data[i].active+'></td>' +*/
                        '<td><div class="editbatch"><a> Edit </a></div></td>' +
                        '<td>'+data[i].noOfStudents+'</td>' +
                       /* '<td>'+data[i].candidatesappeared+'</td>' +
                        '<td>'+data[i].candidatespassed+'</td>' +
                        '<td>'+data[i].candidatesfailed+'</td>' +
                        '<td>'+data[i].passingpercentage+'</td>' +*/
                        '<td>'+data[i].candidatespending+'</td>' +
                        '<td><a href="excelreportbatchwise?batchId='+data[i].batchId+'" target="_blank"> Download</a></td>' +
                    '</tr>');
               /* if(data[i].active == 1){
                    $("#batch"+data[i].batchId+"").children(".batchStatus").text("Enable");
                } else {
                    $("#batch"+data[i].batchId+"").children(".batchStatus").text("Disable");
                }*/
            }

        },


   /*  /*   /*Creating the row accordian for the batch*/
      rowAccordianForBatch: function(e)  {
         var that = e.currentTarget.parentNode;
            var nTr = that;
            var i = $.inArray( nTr, anOpen );


            if ( i === -1 ) {

                table.fnOpen( nTr, this.format(table,nTr), 'details' );
                anOpen.push( nTr );
                 $(that).find('i').toggleClass('fa-plus-circle fa-minus-circle');
            }
            else {

                $(that).find('i').toggleClass('fa-plus-circle fa-minus-circle');
                table.fnClose( nTr );
                anOpen.splice( i, 1 );
            }
    } ,

format : function(table,data) {
     var oData = table.fnGetData( data );
    // `d` is the original data object for the row
    return '<table class="tableAccordion" cellpadding="5" cellspacing="0" border="0" style="padding-left:50px;">'+
        '<tr>'+
            '<td class="simplelabel">BatchStart Date:</td>'+
            '<td>'+oData.validFrom+'</td>'+
            '<td class="simplelabel">BatchEndDate:</td>'+
            '<td>'+oData.validTo+'</td>'+
             '<td class="simplelabel">Passing percentage:</td>'+
             '<td>'+oData.passingpercentage+'</td>' +

        '</tr>'+
        '<tr>'+
            '<td class="simplelabel">Miscellaneousexpenses:</td>'+
            '<td>'+oData.miscellaneous+'</td>'+
            '<td class="simplelabel">Travelling Expenses:</td>'+
            '<td>'+oData.travellingExpense+'</td>'+
            '<td class="simplelabel">Lunch Expenses:</td>'+
            '<td>'+oData.lunchexpenses+'</td>'+
        '</tr>'+
        '<tr>'+
            '<td class="simplelabel">Candidates Appeared:</td>'+
            '<td>'+oData.candidatesappeared+'</td>'+
            '<td class="simplelabel">Candidates Passed:</td>'+
            '<td>'+oData.candidatespassed+'</td>'+
            '<td class="simplelabel">Candidates Failed:</td>'+
            '<td>'+oData.candidatesfailed+'</td>'+

        '</tr>'+
    '</table>';
},

0 个答案:

没有答案