Skip to content

Commit b254036

Browse files
Added Option "DrawCallback", including config samples
http://datatables.net/usage/callbacks#fnDrawCallback
1 parent 4b9f4c8 commit b254036

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
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: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@
6262
6363
</text>
6464
}
65+
@if (!string.IsNullOrEmpty(Model.DrawCallback))
66+
{
67+
<text>
68+
,"fnDrawCallback": @Html.Raw(Model.DrawCallback)
69+
</text>
70+
}
6571
});
6672
@if (Model.ColumnFilter)
6773
{

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)