2017年7月17日 星期一

[jQuery] jQuery plugin DataTables ajax reload 搭配ASP.NET MVC

說明:
使用jQuery plugin DataTables來呈現資料,與資料異動後做reload。


做法:
資料來源為localDB,使用EF code first定義一簡單的Model:

Controller部分,回傳json包在key為data的object內:

最後是View部分:

實際畫面:



參考資料:
https://datatables.net/reference/option/
https://datatables.net/examples/server_side/post.html
http://www.techstrikers.com/Articles/jquery-datatable-bind-json-using-asp.net-mvc5.php
https://datatables.net/reference/api/ajax.reload()
https://editor.datatables.net/examples/simple/inTableControls.html
https://datatables.net/forums/discussion/21164/disable-sorting-of-one-column
https://stackoverflow.com/questions/30627026/jquery-datatables-how-to-add-an-edit-and-delete-option