ASP.net
Awesome
Learn
Forum
Buy
Demos
Sign In
☾
☀
Switch to
Dark
Light
Mode
this site works best with javascript enabled
Ask Question
Tree Grid sort children nodes, not just the roots
Title:
B
I
{code}
?
it is possible to sort the children of each node in the TreeGrid. exemple: wrong - 1 ->3 ->b ->a ->1 ->a ->h ->e ->4 ->z ->a ->2 ->v ->e ->a correct - 1 ->1 ->a ->e ->h ->2 ->a ->e ->v ->3 ->a ->b ->4 ->a ->z
Save Changes
Cancel
Meccanica Rossi
asked 4 days ago
Answers
B
I
{code}
?
Yes, you can sort the children nodes in the TreeGrid, we actually do it in this demo: https://demo.aspnetawesome.com/TreeGrid#Tree-Grid-with-CRUD-operations in the `GridModelBuilder` `GetChildren` or `GetChildrenAsync` you need to sort the data according to the `GridParams`, and usually you would do this by calling `gmb.OrderBy(children.AsQueryable());` example: gmb.GetChildren = (node, nodeLevel) => { var children = result.Where(o => o.Parent == node); return gmb.OrderBy(children.AsQueryable()); };
Save Changes
Cancel
Omu
answered 4 days ago
I see your sample, but not seem sorted by a column (ex. ID)
3 days ago
Meccanica Rossi
the data we used for the demo is not ideal for understanding the demo, but the sorting works, here's a screenshot https://jmp.sh/BqiOJtZv
3 days ago
Omu
Is it possible sort by only one column (ex. id) ?
yesterday
Meccanica Rossi
yes, if you want to remove the sorting from other columns when you click on another use `.SingleColumnSort(true)` on the `Grid`, you can see it here: https://demo.aspnetawesome.com/GridDemo/Sorting (there's a checkbox setting for the demo grid)
yesterday
Omu
It's ok, thank you
17 hours ago
Meccanica Rossi
please
Sign In
to leave an answer
By accessing this site, you agree to store cookies on your device and disclose information in accordance with our
cookie policy
and
privacy policy
.
OK