0

I have a datatable, the first column show agencies assigned to this row, in another column I have a button that when clicked show a form to assign new agencies to this row, everything work well, but for the new agencies added I have to refresh the page to see them, is there any way to add them as soon as I click the button "Assign" ?

here is an image showing what I am talking about :

enter image description here

Thanks.

Sandeep Chatterjee
  • 3,220
  • 9
  • 31
  • 47
user3101157
  • 55
  • 2
  • 8

2 Answers2

0

You can use something like this:

if (success)
{
    var theDiv = $("<li/>");
    theDiv.html("<input type='checkBox' value='"+newItemValue+"'/> " + newItemName);
    theDiv.appendTo($("#theParentElement"));
}

You create a new DOM element when all goes as expected and then you pass it into your main holder.

skoumas
  • 189
  • 3
  • 12
0
function initDataTable() {
   var oOverviewTable =$('#myTable').dataTable(
      {
      "bPaginate": true,
      "bJQueryUI": true,  
      "bLengthChange": false
      "sAjaxSource": '/Helpdesk/ActiveCases/noacceptancetest'
    });
 }

  function RefreshTable(tableId, urlData)
  {
     $.getJSON(urlData, null, function( json )
      {
         table = $(tableId).dataTable();
         oSettings = table.fnSettings();

         table.fnClearTable(this);

     table.fnDraw();
   });
 }

 function reloadTable()
 {
   RefreshTable('#HelpdeskOverview', '/Helpdesk/ActiveCases/noacceptancetest');
  }

 $(document).ready(function () {
     initDataTable();
  });

  //now call reloadTable function in agency assing event

the original post can be seen here

Community
  • 1
  • 1
Mehmet Otkun
  • 1,374
  • 9
  • 22