Skip to content

Commit 9282951

Browse files
committed
Revert "SearchCols fixes"
This reverts commit c3ab6bd. Then re-apply without gitmodules changes
1 parent c3ab6bd commit 9282951

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
}"));
2626
vm.ColumnFilter = true;
2727
vm
28-
.FilterOn("Position", new { sSelector = "#custom-filter-placeholder-position" }, new { sSearch = "Tester" }).Select("Engineer", "Tester", "Manager")
28+
.FilterOn("Position", new { sSelector = "#custom-filter-placeholder-position" }).Select("Engineer", "Tester", "Manager")
2929
.FilterOn("Id").NumberRange()
3030
.FilterOn("Salary", new { sSelector = "#custom-filter-placeholder-salary" }).NumberRange();
3131
//.FilterOn("Number").CheckBoxes(Enum.GetNames(typeof(Numbers)));

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
}
6767
options["fnServerData"] = new JRaw(" function(sSource, aoData, fnCallback) { $.ajax({ 'dataType': 'json', 'type': 'POST', 'url': sSource, 'data': aoData, 'success': fnCallback })}");
6868
options["aoColumnDefs"] = new JRaw(Model.ColumnDefsString);
69-
options["aoSearchCols"] = Model.SearchCols;
69+
options["aoSearchCols"] = new JRaw(Model.ColumnInitialSearchString);
7070
if (Model.JsOptions.Any())
7171
{
7272
foreach (var jsOption in Model.JsOptions)

Mvc.JQuery.Datatables/DataTableConfigVm.cs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,11 @@ public string ColumnDefsString
6161

6262
public bool AutoWidth { get; set; }
6363

64-
public JToken SearchCols
64+
public string ColumnInitialSearchString
6565
{
6666
get
6767
{
68-
var initialSearches = Columns
69-
.Select(c => c.Searchable & c.SearchCols != null ? c.SearchCols : null as object).ToArray();
70-
return new JArray(initialSearches);
68+
return ConvertColumnDefsInitialSearchToJson(Columns);
7169
}
7270
}
7371

@@ -258,6 +256,13 @@ private static string ConvertColumnDefsToJson(IEnumerable<ColDef> columns)
258256
return "[]";
259257
}
260258

259+
private static string ConvertColumnDefsInitialSearchToJson(IEnumerable<ColDef> columns)
260+
{
261+
var initialSearches = columns
262+
.Select(c => c.Searchable & c.SearchCols != null ? c.SearchCols.ToString() : null as object).ToArray();
263+
return new JArray(initialSearches).ToString();
264+
}
265+
261266
private static string ConvertColumnSortingToJson(IEnumerable<ColDef> columns)
262267
{
263268
var sortList = columns.Select((c, idx) => c.SortDirection == SortDirection.None ? new dynamic[] { -1, "" } : (c.SortDirection == SortDirection.Ascending ? new dynamic[] { idx, "asc" } : new dynamic[] { idx, "desc" })).Where(x => x[0] > -1).ToArray();

0 commit comments

Comments
 (0)