Tree Table
Tree Table
Hello,
I have a custom tree table and the search has been added to it, the problem is when the search is done, the table follows the alphabet and the tree is destroyed, I tried the code to prevent the sort but its not working: "aoColumnDefs": [
{ "bSortable": false, "aTargets": [0] },
{ "bSortable": false, "aTargets": [1] }],
sortAscending: false, sortDescending: false,
bSortable: false, ordering: false, order: false, sort: false,
the is my code in tbody:
Html:
ID: @item.ID __ Name: @item.Name | @if (lst.Where(x => x.PrID == (int)Pages.Location).FirstOrDefault() != null && lst.Where(x => x.PrID == (int)Pages.Location).FirstOrDefault().CanEdit == true) { } @if (lst.Where(x => x.PrID == (int)Pages.Location).FirstOrDefault() != null && lst.Where(x => x.PrID == (int)Pages.Location).FirstOrDefault().CanDelete == true) { } @if (lst.Where(x => x.PrID == (int)Pages.Location).FirstOrDefault() != null && lst.Where(x => x.PrID == (int)Pages.Location).FirstOrDefault().CanAdd == true) { } |
javascript:
var table = $(tblLocation).DataTable({
info: true,
ordering: false,
dom: '<"toolbar"><"toolbar1">Bfrtip',
buttons: [
{
name: 'copyBtn',
text: '+ @Dictionary.DictionaryWord(Word.AddNew)',
action: function (e, dt, node, config) {
addNewRow(this);
}
}
], "aoColumnDefs": [
{ "bSortable": false, "aTargets": [0] },
{ "bSortable": false, "aTargets": [1] }],
sortAscending: false, sortDescending: false,
bSortable: false, ordering: false, order: false, sort: false,
language: {
processing: "@Dictionary.DictionaryWord(Word.Processing)",
search: "@Dictionary.DictionaryWord(Word.Search) :",
lengthMenu: "@Dictionary.DictionaryWord(Word.Show) MENU @Dictionary.DictionaryWord(Word.Data)",
info: "@Dictionary.DictionaryWord(Word.Showing) START @Dictionary.DictionaryWord(Word.To) END @Dictionary.DictionaryWord(Word.FromSource) TOTAL @Dictionary.DictionaryWord(Word.Entry)",
infoFiltered: "( @Dictionary.DictionaryWord(Word.InfoFiltered) MAX @Dictionary.DictionaryWord(Word.Entry) )",
infoPostFix: "",
loadingRecords: "@Dictionary.DictionaryWord(Word.Loading)",
zeroRecords: "@Dictionary.DictionaryWord(Word.ZeroRecords)",
emptyTable: "@Dictionary.DictionaryWord(Word.EmptyTable)",
paginate: {
first: "@Dictionary.DictionaryWord(Word.First)",
previous: "@Dictionary.DictionaryWord(Word.Previous)",
next: "@Dictionary.DictionaryWord(Word.Next)",
last: "@Dictionary.DictionaryWord(Word.Last)"
},
aria: {
sortAscending: "@Dictionary.DictionaryWord(Word.SortAscending)",
sortDescending: "@Dictionary.DictionaryWord(Word.SortDescending)"
},
infoEmpty: "@Dictionary.DictionaryWord(Word.Showing) 0 @Dictionary.DictionaryWord(Word.To) 0 @Dictionary.DictionaryWord(Word.FromSource) 0 @Dictionary.DictionaryWord(Word.Entry)"
}
});
Is There Is Away to prevent the sort during search ?
Answers
Only by disabling the sorting entirely I'm afraid. That's something that is fairly baked into DataTables.
Allan