From b254036801727640d898e405259fd9859d4a6330 Mon Sep 17 00:00:00 2001 From: Dreiundzwanzig Date: Tue, 15 Oct 2013 16:02:28 +0200 Subject: [PATCH 1/2] Added Option "DrawCallback", including config samples http://datatables.net/usage/callbacks#fnDrawCallback --- Mvc.JQuery.Datatables.Example/Views/Home/Index.cshtml | 7 ++++++- .../Views/Shared/DataTable.cshtml | 6 ++++++ Mvc.JQuery.Datatables/DataTableConfigVm.cs | 2 ++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Mvc.JQuery.Datatables.Example/Views/Home/Index.cshtml b/Mvc.JQuery.Datatables.Example/Views/Home/Index.cshtml index 3a2b628..77553b2 100644 --- a/Mvc.JQuery.Datatables.Example/Views/Home/Index.cshtml +++ b/Mvc.JQuery.Datatables.Example/Views/Home/Index.cshtml @@ -60,7 +60,7 @@ public class SomeController : Controller .FilterOn("Id").NumberRange(); //.FilterOn("Number").CheckBoxes(Enum.GetNames(typeof(Numbers))); vm.StateSave = true; - + //vm.DrawCallback = "drawCallback"; if (Request.QueryString["lang"] == "de") { @@ -91,6 +91,11 @@ public class SomeController : Controller function test(data, type, full) { return '' + data + ''; } + + function drawCallback(oSettings) { + console.log('fnDrawCallback fired'); + console.log(oSettings); + } @Html.Partial("DataTable", vm) diff --git a/Mvc.JQuery.Datatables.Templates/Views/Shared/DataTable.cshtml b/Mvc.JQuery.Datatables.Templates/Views/Shared/DataTable.cshtml index 3f7ae90..6ccc98f 100644 --- a/Mvc.JQuery.Datatables.Templates/Views/Shared/DataTable.cshtml +++ b/Mvc.JQuery.Datatables.Templates/Views/Shared/DataTable.cshtml @@ -62,6 +62,12 @@ } + @if (!string.IsNullOrEmpty(Model.DrawCallback)) + { + + ,"fnDrawCallback": @Html.Raw(Model.DrawCallback) + + } }); @if (Model.ColumnFilter) { diff --git a/Mvc.JQuery.Datatables/DataTableConfigVm.cs b/Mvc.JQuery.Datatables/DataTableConfigVm.cs index 19222bb..14f4cc6 100644 --- a/Mvc.JQuery.Datatables/DataTableConfigVm.cs +++ b/Mvc.JQuery.Datatables/DataTableConfigVm.cs @@ -123,6 +123,8 @@ public string ColumnSortingString public string Language { get; set; } + public string DrawCallback { get; set; } + public string GetFilterType(string columnName, Type type) { foreach (Func filterTypeRule in FilterTypeRules) From f54a85f1640bf713676d2c7ed4a039b57b6ec5d8 Mon Sep 17 00:00:00 2001 From: Dreiundzwanzig Date: Tue, 15 Oct 2013 16:04:18 +0200 Subject: [PATCH 2/2] Fixed intends --- .../Views/Shared/DataTable.cshtml | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/Mvc.JQuery.Datatables.Templates/Views/Shared/DataTable.cshtml b/Mvc.JQuery.Datatables.Templates/Views/Shared/DataTable.cshtml index 6ccc98f..56e7910 100644 --- a/Mvc.JQuery.Datatables.Templates/Views/Shared/DataTable.cshtml +++ b/Mvc.JQuery.Datatables.Templates/Views/Shared/DataTable.cshtml @@ -59,7 +59,6 @@ { ,"oLanguage": @Html.Raw(@Model.Language) - } @if (!string.IsNullOrEmpty(Model.DrawCallback)) @@ -71,12 +70,12 @@ }); @if (Model.ColumnFilter) { - - dt.columnFilter({ - sPlaceHolder: "head:before", - aoColumns: [@Html.Raw(Model.ColumnFiltersString)] - }); - + + dt.columnFilter({ + sPlaceHolder: "head:before", + aoColumns: [@Html.Raw(Model.ColumnFiltersString)] + }); + } })();