Tree Table

Tree Table

ibrahim991ibrahim991 Posts: 1Questions: 1Answers: 0

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:

@foreach (var item in Model) { string display = ""; if (item.Parent == 0) { display = "block"; } else if (Model.Where(x => x.ID == item.Parent).ToList().ToArray().Length == 0) { display = "block"; item.Loc_Level = 1; } else { display = "none"; } int padd = Convert.ToInt32(item.Loc_Level) * 30; string padStr = padd.ToString() + "px"; string padding = IsRTL == true ? "right" : "left"; string arrow = "fa fa-plus-circle"; }
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

  • allanallan Posts: 61,740Questions: 1Answers: 10,111 Site admin

    Only by disabling the sorting entirely I'm afraid. That's something that is fairly baked into DataTables.

    Allan

This discussion has been closed.