Skip to content

Commit fb10183

Browse files
committed
Merge pull request mcintyre321#58 from Dreiundzwanzig/fnDrawCallback
Added Option "DrawCallback"
2 parents d91d356 + f54a85f commit fb10183

File tree

3 files changed

+20
-8
lines changed

3 files changed

+20
-8
lines changed

Mvc.JQuery.Datatables.Example/Views/Home/Index.cshtml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public class SomeController : Controller
6060
.FilterOn("Id").NumberRange();
6161
//.FilterOn("Number").CheckBoxes(Enum.GetNames(typeof(Numbers)));
6262
vm.StateSave = true;
63-
63+
//vm.DrawCallback = "drawCallback";
6464
6565
if (Request.QueryString["lang"] == "de")
6666
{
@@ -91,6 +91,11 @@ public class SomeController : Controller
9191
function test(data, type, full) {
9292
return '<i>' + data + '</i>';
9393
}
94+
95+
function drawCallback(oSettings) {
96+
console.log('fnDrawCallback fired');
97+
console.log(oSettings);
98+
}
9499
</script>
95100
@Html.Partial("DataTable", vm)
96101

Mvc.JQuery.Datatables.Templates/Views/Shared/DataTable.cshtml

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,18 +59,23 @@
5959
{
6060
<text>
6161
,"oLanguage": @Html.Raw(@Model.Language)
62-
62+
</text>
63+
}
64+
@if (!string.IsNullOrEmpty(Model.DrawCallback))
65+
{
66+
<text>
67+
,"fnDrawCallback": @Html.Raw(Model.DrawCallback)
6368
</text>
6469
}
6570
});
6671
@if (Model.ColumnFilter)
6772
{
68-
<text>
69-
dt.columnFilter({
70-
sPlaceHolder: "head:before",
71-
aoColumns: [@Html.Raw(Model.ColumnFiltersString)]
72-
});
73-
</text>
73+
<text>
74+
dt.columnFilter({
75+
sPlaceHolder: "head:before",
76+
aoColumns: [@Html.Raw(Model.ColumnFiltersString)]
77+
});
78+
</text>
7479
}
7580
})();
7681
</script>

Mvc.JQuery.Datatables/DataTableConfigVm.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ public string ColumnSortingString
123123

124124
public string Language { get; set; }
125125

126+
public string DrawCallback { get; set; }
127+
126128
public string GetFilterType(string columnName, Type type)
127129
{
128130
foreach (Func<string, Type, string> filterTypeRule in FilterTypeRules)

0 commit comments

Comments
 (0)