Datatable is hidding data after resending the request

Datatable is hidding data after resending the request

PuneetPuneet Posts: 6Questions: 3Answers: 0

I am working on jQuery DataTables and it is working fine on first click on Submit button,But when I click on Submit button, it is hiding all the data.
MY code is :

if(typeof table === 'undefined'){
  table = $("#financeDataTable").DataTable( {
    "initComplete": function(oSettings, json) {
      this.fnHideEmptyColumns(this);
      $('#lblReportHeader').html(reportHeader);
      $('#lblFromDate').html(fromDateHeader);
      $('#lblToDate').html(fromToHeader);
      $("#txtReportTypeHidden").val(reportType);
      $("#txtReportSubTypeHidden").val(reportSubType);
      $("#txtFromDateHidden").val( fromDate);
      $("#txtToDateHidden").val(toDate);
      $('#tblReportHeader').show();
    },
    "searching": false,
    "retrieve": true, 
    "destroy": true,
    "ajax": "./getReportDetails",
    "jQueryUI": true,
    "dom": 'Bfr<"H"lf><"datatable-scroll"t><"F"ip>',
    "fnServerParams": function ( data ) {
      newData=data;
      newData.push( { "name": "reportType", "value": reportType }, { "name": "reportSubType", "value": reportSubType}, { "name": "fromDate", "value": fromDate}, { "name": "toDate", "value": toDate}, { "name": "cif", "value": ""}, { "name": "channel", "value": ""}, { "name": "userType", "value": ""});
    },
    "columns": [
      { "mData": "1", "sTitle": ""},
      { "mData": "username", "sTitle": "username"},
      { "mData": "transferType", "sTitle": "transferType"},
      { "mData": "fromAccount", "sTitle": "fromAccount"},
      { "mData": "toAccount", "sTitle": "toAccount"},
      { "mData": "amount", "sTitle": "amount"},
      { "mData": "currency", "sTitle": "currency"},
      { "mData": "transferDate", "sTitle": "transferDate"},
      { "mData": "creditDebitFlag", "sTitle": "creditDebitFlag"},
      { "mData": "fromAccountType", "sTitle": "fromAccountType"},
      { "mData": "toAccountType", "sTitle": "toAccountType"},
      { "mData": "impsChannelType", "sTitle": "impsChannelType"},
      { "mData": "impsTranType", "sTitle": "impsTranType"},
      { "mData": "IFSCCode", "sTitle": "IFSCCode"},
      { "mData": "narration", "sTitle": "narration"},
      { "mData": "customerID", "sTitle": "customerID"},
      { "mData": "customerName", "sTitle": "customerName"},
      { "mData": "fromMMID", "sTitle": "fromMMID"},
      { "mData": "fromMobileNo", "sTitle": "fromMobileNo"},
      { "mData": "toMMID", "sTitle": "toMMID"},
      { "mData": "toMobileNo", "sTitle": "toMobileNo"},
      { "mData": "paymentType", "sTitle": "paymentType"},
      { "mData": "transReferenceId", "sTitle": "transReferenceId"},
      { "mData": "transactionStatus", "sTitle": "transactionStatus"}
    ]
  } ); 
}else{
  var settings =  {  
    "initComplete": function(oSettings, json) {
      this.fnHideEmptyColumns(this);
      $('#lblReportHeader').html(reportHeader);
      $('#lblFromDate').html(fromDateHeader);
      $('#lblToDate').html(fromToHeader);
      $('#tblReportHeader').show();
      $("#txtReportTypeHidden").val(reportType);
      $("#txtReportSubTypeHidden").val(reportSubType);
      $("#txtFromDateHidden").val( fromDate);
      $("#txtToDateHidden").val(toDate);
    },
    "retrieve": true, 
    "searching": false,
    "destroy": true,
    "ajax": "./getReportDetails", 
    "jQueryUI": true,
    "dom": 'Bfr<"H"lf><"datatable-scroll"t><"F"ip>',
    "fnServerParams": function ( data ) {
      newData=data;
      newData.push( { "name": "reportType", "value": reportType }, { "name": "reportSubType", "value": reportSubType}, { "name": "fromDate", "value": fromDate}, { "name": "toDate", "value": toDate}, { "name": "cif", "value": ""}, { "name": "channel", "value": ""}, { "name": "userType", "value": ""});
    },
    "columns": [
      { "mData": "1", "sTitle": ""},
      { "mData": "username", "sTitle": "username"},
      { "mData": "transferType", "sTitle": "transferType"},
      { "mData": "fromAccount", "sTitle": "fromAccount"},
      { "mData": "toAccount", "sTitle": "toAccount"},
      { "mData": "amount", "sTitle": "amount"},
      { "mData": "currency", "sTitle": "currency"},
      { "mData": "transferDate", "sTitle": "transferDate"},
      { "mData": "creditDebitFlag", "sTitle": "creditDebitFlag"},
      { "mData": "fromAccountType", "sTitle": "fromAccountType"},
      { "mData": "toAccountType", "sTitle": "toAccountType"},
      { "mData": "impsChannelType", "sTitle": "impsChannelType"},
      { "mData": "impsTranType", "sTitle": "impsTranType"},
      { "mData": "IFSCCode", "sTitle": "IFSCCode"},
      { "mData": "narration", "sTitle": "narration"},
      { "mData": "customerID", "sTitle": "customerID"},
      { "mData": "customerName", "sTitle": "customerName"},
      { "mData": "fromMMID", "sTitle": "fromMMID"},
      { "mData": "fromMobileNo", "sTitle": "fromMobileNo"},
      { "mData": "toMMID", "sTitle": "toMMID"},
      { "mData": "toMobileNo", "sTitle": "toMobileNo"},
      { "mData": "paymentType", "sTitle": "paymentType"},
      { "mData": "transReferenceId", "sTitle": "transReferenceId"},
      { "mData": "transactionStatus", "sTitle": "transactionStatus"}
    ]};
  table.destroy();
  $("#financeDataTable").DataTable(settings);   
}

Please let me know why this is happening or what is the wrong in my code.

Check the screenshots on stackoverflow : http://stackoverflow.com/questions/32718304/datatable-is-hidding-data-after-resending-the-request

Answers

  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395

    What is supposed to happen when clicking your "Submit" button?

  • PuneetPuneet Posts: 6Questions: 3Answers: 0

    Please check the stackoverflow link. On the click of submit button, my datatable should be loaded with new data or refresh with old data.

  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395

    I mean what function is called by your "Submit"?

  • PuneetPuneet Posts: 6Questions: 3Answers: 0

    The given code is inner part of "$('#btnSubmit').click(function(){"

  • allanallan Posts: 63,745Questions: 1Answers: 10,509 Site admin

    That code isn't shown above. There is no reference to btnSubmit.

    Please link to a test case showing the issue, as required in the forum rules. Without a test case we can't offer any help.

    Allan

This discussion has been closed.