child is Not working for second time after submit

child is Not working for second time after submit

ahsan007ahsan007 Posts: 2Questions: 2Answers: 0

i m working with ajax return , my problem is when my page is loaded and ajax request is send row.child().show works fine, bt if i send another ajax request data loaded successfully, console.log(row.data()); show the object bt rowchild() is not working
<code>
currentRequestReturnedRatioByCity = jQuery.ajax({
url: "ajax_files/dashbord_ajax.php",
type: "POST",
data: formData,
beforeSend: function()
{
//$('#nopagination_data_tables_for').DataTable().destroy();
},
success:function(response)
{
if(response!='')
{

                    obj = jQuery.parseJSON(response);
                    //console.log(obj);

                    //$('#showReturnedRatioByCity').html(response);
                    if(table)
                    {
                        table.clear();
                    }
                    table = $('#nopagination_data_tables_for').DataTable({ 
                                                                    "paging": false,
                                                                    "ordering": false,
                                                                    "info": false,
                                                                    destroy: true,
                                                                    data: obj.data,
                                                                    columns: [
                                                                                    {
                                                                                        "className":      'details-control',
                                                                                        "orderable":      false,
                                                                                        "data":           null,
                                                                                        "defaultContent": ''
                                                                                    },
                                                                                    { data: "name" },
                                                                                    { data: "total_parcels" },
                                                                                    { data: "total_returned" },
                                                                                    { data: "total_parcels" },

                                                                                ]
                                                                  });


                    $('#pleaseWaitReturnByCity').slideUp('slow',function(){
                        $('#tableForReturnRatioByCity').slideDown('slow');
                    });
                    $('#nopagination_data_tables_for tbody').on('click', 'td.details-control', function () {
                        var tr = $(this).closest('tr');
                        var row = table.row( tr );


                        if ( row.child.isShown() ) {
                            // This row is already open - close it
                            row.child.hide();
                            tr.removeClass('shown');
                        }
                        else {
                            // Open this row
                            console.log(row.data());
                            var data = row.data();
                            var rowDataForFormate =  '<table cellpadding="5" cellspacing="0" border="0"  class="table table-hover" ><tr><td> not working</td></tr></table>';
                            row.child(rowDataForFormate);
                            tr.addClass('shown');
                        }
                    } );
                }
                send_request = '0';
            }
        });

</code>

This discussion has been closed.