Refresh Datatable and paging data after editing data
Refresh Datatable and paging data after editing data
Am using the Datatable plugin , but i am not using the Editor plugin. I have the controller where it populates the model data from the database repository . It's not ajax call. I select the rows in the datatable and click on the Edit button and it opens up the model/view . after i submit the data , i have a code to load the page but the datatable is not refreshed. could you please advise. Is there anything we can do to refresh the table without the ajax call?. I tried table.draw () but this is not working.
Answers
Hi @egladstone ,
We're happy to take a look, but it would help, as per the forum rules, if you could link to a running test case showing the issue so we can offer some help. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.
Cheers,
Colin
Here's the code
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.18/css/jquery.dataTables.css">
<script type="text/javascript" src="https://cdn.datatables.net/1.10.18/js/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/select/1.2.6/js/dataTables.select.min.js"></script>
<link rel="stylesheet" type="text/css" href="~/Content/Styles/TableSelection.css" />
@using PagedList;
@using PagedList.Mvc;
@using Career.WebUI.Models;
@model TemplatesListViewModel
@{
}
$(document).ready(function () { $('#example').DataTable({ var table = $('#example').DataTable(); $('#example tbody').on('click', 'tr', function () { $(this).toggleClass('selected'); }); }); function btnEdit(btn) { var table = $('#example').DataTable(); var values = new Array(); var oData = table.rows('.selected').data(); for (var i = 0; i < oData.length ; i++) { values.push(oData[i][1]); } $('input[name=txthidden]').val(values.join(",")); }Completed :
@Html.RadioButtonFor(m => m.Completed, "Yes", "Yes")
@Html.RadioButtonFor(m => m.Completed, "No", "No")
<
div style="width:100%" id="content">
</tbody>
Controller.cs
[HttpPost]
public ActionResult Edit(FormCollection form, string txthidden, TemplatesListViewModel Editview)
{
Domain.Entities.Career cp = new Domain.Entities.Career();
if (ModelState.IsValid)
{
}
};
return View(viewmodel);
}