diff --git a/NzbDrone.Web/Controllers/HistoryController.cs b/NzbDrone.Web/Controllers/HistoryController.cs
index 608b307ae..ba06654bc 100644
--- a/NzbDrone.Web/Controllers/HistoryController.cs
+++ b/NzbDrone.Web/Controllers/HistoryController.cs
@@ -19,6 +19,11 @@ namespace NzbDrone.Web.Controllers
}
public ActionResult Index()
+ {
+ return View();
+ }
+
+ public JsonResult AjaxBinding()
{
var history = _historyProvider.AllItemsWithRelationships().Select(h => new HistoryModel
{
@@ -36,9 +41,11 @@ namespace NzbDrone.Web.Controllers
EpisodeId = h.EpisodeId
}).OrderByDescending(h => h.Date).ToList();
- var serialized = new JavaScriptSerializer().Serialize(history);
-
- return View((object)serialized);
+ return Json(new
+ {
+ aaData = history
+ },
+ JsonRequestBehavior.AllowGet);
}
public JsonResult Trim()
diff --git a/NzbDrone.Web/NzbDrone.Web.csproj b/NzbDrone.Web/NzbDrone.Web.csproj
index db346a7f0..52662b62a 100644
--- a/NzbDrone.Web/NzbDrone.Web.csproj
+++ b/NzbDrone.Web/NzbDrone.Web.csproj
@@ -264,6 +264,7 @@
+
diff --git a/NzbDrone.Web/Scripts/DataTables-1.9.0/media/js/jquery.dataTables.reloadAjax.js b/NzbDrone.Web/Scripts/DataTables-1.9.0/media/js/jquery.dataTables.reloadAjax.js
new file mode 100644
index 000000000..56773bfc8
--- /dev/null
+++ b/NzbDrone.Web/Scripts/DataTables-1.9.0/media/js/jquery.dataTables.reloadAjax.js
@@ -0,0 +1,39 @@
+$.fn.dataTableExt.oApi.fnReloadAjax = function (oSettings, sNewSource, fnCallback, bStandingRedraw) {
+ if (typeof sNewSource != 'undefined' && sNewSource != null) {
+ oSettings.sAjaxSource = sNewSource;
+ }
+ this.oApi._fnProcessingDisplay(oSettings, true);
+ var that = this;
+ var iStart = oSettings._iDisplayStart;
+ var aData = [];
+
+ this.oApi._fnServerParams(oSettings, aData);
+
+ oSettings.fnServerData(oSettings.sAjaxSource, aData, function (json) {
+ /* Clear the old information from the table */
+ that.oApi._fnClearTable(oSettings);
+
+ /* Got the data - add it to the table */
+ var aData = (oSettings.sAjaxDataProp !== "") ?
+ that.oApi._fnGetObjectDataFn(oSettings.sAjaxDataProp)(json) : json;
+
+ for (var i = 0; i < aData.length; i++) {
+ that.oApi._fnAddData(oSettings, aData[i]);
+ }
+
+ oSettings.aiDisplay = oSettings.aiDisplayMaster.slice();
+ that.fnDraw();
+
+ if (typeof bStandingRedraw != 'undefined' && bStandingRedraw === true) {
+ oSettings._iDisplayStart = iStart;
+ that.fnDraw(false);
+ }
+
+ that.oApi._fnProcessingDisplay(oSettings, false);
+
+ /* Callback user function - for event handlers etc */
+ if (typeof fnCallback == 'function' && fnCallback != null) {
+ fnCallback(oSettings);
+ }
+ }, oSettings);
+}
\ No newline at end of file
diff --git a/NzbDrone.Web/Scripts/NzbDrone/grid.js b/NzbDrone.Web/Scripts/NzbDrone/grid.js
index 2dffa4a7c..94bcaceda 100644
--- a/NzbDrone.Web/Scripts/NzbDrone/grid.js
+++ b/NzbDrone.Web/Scripts/NzbDrone/grid.js
@@ -52,4 +52,14 @@ function createImageAjaxLink(url, image, alt, title, classes) {
"";
return html;
+}
+
+//Reload/Redraw the grid from the server (bServerSide == true)
+function redrawGrid() {
+ oTable.fnDraw();
+}
+
+//Force reload using Ajax Binding (bServerSide == false)
+function reloadGrid() {
+ oTable.fnReloadAjax();
}
\ No newline at end of file
diff --git a/NzbDrone.Web/Views/History/Index.cshtml b/NzbDrone.Web/Views/History/Index.cshtml
index bc4a4eca7..5396da812 100644
--- a/NzbDrone.Web/Views/History/Index.cshtml
+++ b/NzbDrone.Web/Views/History/Index.cshtml
@@ -5,8 +5,8 @@
@{ViewBag.Title = "History";}
@section ActionMenu{
}
@section HeaderContent
@@ -50,51 +50,50 @@
$(document).ready(function() {
$('#historyGrid').removeClass('hidden-grid');
- oTable = $('.dataTablesGrid').dataTable({
- //"sAjaxSource": "History/AjaxBinding",
- //"bProcessing": true,
+ oTable = $('#historyGrid').dataTable({
+ "sAjaxSource": "History/AjaxBinding",
+ "bServerSide": false,
+ "bProcessing": true,
"bShowAll": false,
- "aaData": @Html.Raw(Model),
- "bPaginate": true,
- "bLengthChange": false,
- "bFilter": true,
- "bSort": true,
- "bInfo": true,
- "bAutoWidth": false,
- "iDisplayLength": 20,
- "sPaginationType": "four_button",
- "aoColumns": [
- { sWidth: '20px', "bSortable": false, "mDataProp": "Indexer", "fnRender": function (row) {
- return "";
- }
- }, //Image
- { sWidth: 'auto', "mDataProp": "SeriesTitle" }, //Series Title
- { sWidth: '80px', "mDataProp": "EpisodeNumbering", "bSortable": false }, //EpisodeNumbering
- { sWidth: 'auto', "mDataProp": "EpisodeTitle", "bSortable": false }, //Episode Title
- { sWidth: '70px', "mDataProp": "Quality", "bSortable": false }, //Quality
- { sWidth: '150px', "mDataProp": "Date" }, //Grabbed On
- { sWidth: '40px', "mDataProp": "HistoryId", "bSortable": false, "fnRender": function (row) {
- var deleteImage = "";
- var redownloadImage = "";
+ "bPaginate": true,
+ "bLengthChange": false,
+ "bFilter": true,
+ "bSort": true,
+ "bInfo": true,
+ "bAutoWidth": false,
+ "iDisplayLength": 20,
+ "sPaginationType": "four_button",
+ "aoColumns": [
+ { sWidth: '20px', "bSortable": false, "mDataProp": "Indexer", "fnRender": function (row) {
+ return "";
+ }
+ }, //Image
+ { sWidth: 'auto', "mDataProp": "SeriesTitle" }, //Series Title
+ { sWidth: '80px', "mDataProp": "EpisodeNumbering", "bSortable": false }, //EpisodeNumbering
+ { sWidth: 'auto', "mDataProp": "EpisodeTitle", "bSortable": false }, //Episode Title
+ { sWidth: '70px', "mDataProp": "Quality", "bSortable": false }, //Quality
+ { sWidth: '150px', "mDataProp": "Date" }, //Grabbed On
+ { sWidth: '40px', "mDataProp": "HistoryId", "bSortable": false, "fnRender": function (row) {
+ var deleteImage = "";
+ var redownloadImage = "";
- return deleteImage + redownloadImage;
- //return createImageAjaxLink('/History/Delete?historyId=' + row.aData["HistoryId"], '../../Content/Images/X.png', 'Delete', 'Delete from History', 'searchImage');
- }
- }, //Actions
- {
- sWidth: 'auto',
- "mDataProp": "Details",
- "bSortable": false,
- "bVisible": false,
- "fnRender": function(row) {
- var result = "Overview: " + row.aData["EpisodeOverview"] + "
" +
- "NZB Title: " + row.aData["NzbTitle"] + "
" +
- "Proper: " + row.aData["IsProper"];
- return result;
- }
- } //Details
- ],
- "aaSorting": [[5, 'desc']]
+ return deleteImage + redownloadImage;
+ }
+ }, //Actions
+ {
+ sWidth: 'auto',
+ "mDataProp": "Details",
+ "bSortable": false,
+ "bVisible": false,
+ "fnRender": function(row) {
+ var result = "Overview: " + row.aData["EpisodeOverview"] + "
" +
+ "NZB Title: " + row.aData["NzbTitle"] + "
" +
+ "Proper: " + row.aData["IsProper"];
+ return result;
+ }
+ } //Details
+ ],
+ "aaSorting": [[5, 'desc']]
});
});
diff --git a/NzbDrone.Web/Views/Log/Index.cshtml b/NzbDrone.Web/Views/Log/Index.cshtml
index 60683569d..0ad76834a 100644
--- a/NzbDrone.Web/Views/Log/Index.cshtml
+++ b/NzbDrone.Web/Views/Log/Index.cshtml
@@ -5,7 +5,7 @@
@{ ViewBag.Title = "Logs";}
@section ActionMenu{
}
diff --git a/NzbDrone.Web/Views/Shared/_ReferenceLayout.cshtml b/NzbDrone.Web/Views/Shared/_ReferenceLayout.cshtml
index 1f9740ac6..430fbd698 100644
--- a/NzbDrone.Web/Views/Shared/_ReferenceLayout.cshtml
+++ b/NzbDrone.Web/Views/Shared/_ReferenceLayout.cshtml
@@ -35,6 +35,7 @@
@Html.IncludeScript("NzbDrone/AutoBind.js")
@Html.IncludeScript("NzbDrone/grid.js")
@Html.IncludeScript("DataTables-1.9.0/media/js/jquery.dataTables.min.js")
+ @Html.IncludeScript("DataTables-1.9.0/media/js/jquery.dataTables.reloadAjax.js")
@Html.IncludeScript("DataTables-1.9.0/media/js/jquery.dataTables.editable.js")
@Html.IncludeScript("DataTables-1.9.0/media/js/jquery.jeditable.js")
@Html.IncludeScript("DataTables-1.9.0/media/js/jquery.validate.js")