0

fnOpen(indexOfRow,oTable,cssClass); を使用して、dataTable(Parent) に新しい行を作成することにより、dataTable(parent) 内に新しい dataTable(child) を作成しています。このテーブルを閉じると、dataTable(child) が破棄されます。破棄しています! しかし、dataTable(child) を破棄した後、「indexOfRow」で作成された行が残ります。子データテーブルを格納していたこの行を取り除きたい!!

ありがとう

/* snippet of the code */


$('#example tbody td:nth-child(n+2) ').on('click', function() {

    AnalyticalRole = rowValue(this);
    RotationPeriod = headerValue(this);

    var result=[],divAjax;
    nTr = $(this).parents('tr')[0]; /* indexOfRow: where i want to add need row, and this row will house my new datatable 
                                            This row has only one td with colspan=9
                                        */
     $.support.cors = true;
        $.ajax({
            url: REMOTE_CONTEXT_PATH+"detailsofcredits",
            dataType:"json",
            contentType:'application/json',
            crossDomain:true,
            data: {role:AnalyticalRole,rotationMonths:RotationPeriod},
            success: function (data) { 


                $.each(data,function(i,obj){                        
                    temp= {OrganizationName:obj.orgName,AnalystName:obj.analystName,CurrentRole:obj.currentRole,CurrentPrimary:obj.currentPrimary,RMRPrimary:obj.rmrPrimary,RMROther:obj.rmrOther,RMRChair:obj.rmrChair,CMR:obj.cmr}
                    result.push(temp);
                });

                if(result == 0 || result== null){
                    alert("No data found for the request");
                    table2Id.fnDestroy();
                    $("#div1").hide(); 

                    table2Id = 0;
                }
                else{
                    if(table2Id == 0){                        
                        divAjax = $("#div1").html(ajaxDataTableIntialisation(result));            
                    }
                    else{                    
                        table2Id.fnDestroy();
                        divAjax = $("#div1").html(ajaxDataTableIntialisation(result));            
                    }
                    table1Id.fnOpen(nTr, divAjax, 'dispaly'); /* opening new table at nTr*/
                    isTableTwoOpen=5;
                    $("#div1").show();
                }



            }
        })
        headerPrint(this);
        });

        $("body").on('click',"#closeTable2,#example>thead>tr>th", function()
        {
        table2Id.fnDestroy();
        /* I want to add sumthing here like.. fnDeleterow etc to delete the row created at nTr */
        $("#div1").hide(); 
        table2Id = 0;

        });

/* 上記のコードから呼び出される関数 */

function ajaxDataTableIntialisation(data){
table2Id= $("#table2").dataTable(
        {
            "bRetrieve" : true,
            "bPaginate":true,
            "aaData": data,
            "aoColumns": [
                          { "mDataProp": "OrganizationName" },
                          { "mDataProp": "AnalystName" },
                          { "mDataProp": "CurrentRole" },
                          { "mDataProp": "CurrentPrimary" },
                          { "mDataProp": "RMRPrimary" },
                          { "mDataProp": "RMROther" },
                          { "mDataProp": "RMRChair" },
                          { "mDataProp": "CMR" },]    

        })

}

4

0 に答える 0