# Master Detail Hierarchy - How to set default sort

**URL:** <https://forum.radzen.com/t/master-detail-hierarchy-how-to-set-default-sort/1661>\
**Category:** Uncategorized\
**Created:** [September 27, 2019, 6:26pm UTC](https://forum.radzen.com/t/master-detail-hierarchy-how-to-set-default-sort/1661 "2019-09-27T18:26:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![scjhnsn](https://forum.radzen.com/user_avatar/forum.radzen.com/scjhnsn/32/161_2.png) [@scjhnsn](https://forum.radzen.com/u/scjhnsn)\
**Post date:** [September 27, 2019, 6:26pm UTC](https://forum.radzen.com/t/master-detail-hierarchy-how-to-set-default-sort/1661/1 "2019-09-27T18:26:51Z")

</div>

When I have a Master Detail Hierarchy, I don't know how to set the default sort of the Detail grid the user drills into. I can't see anyway to do it either on the master page or when I Edit the Template.

---

<div class="post-metadata">

**Author:** ![enchev](https://forum.radzen.com/user_avatar/forum.radzen.com/enchev/32/16_2.png) [@enchev](https://forum.radzen.com/u/enchev)\
**Post date:** [September 28, 2019, 5:38am UTC](https://forum.radzen.com/t/master-detail-hierarchy-how-to-set-default-sort/1661/2 "2019-09-28T05:38:07Z")

</div>

The master data are retrieved using LoadData event of the master grid - you can set default order there. For example with Orders -\> OrderDetails

 ![image](https://forum.radzen.com/uploads/default/original/2X/f/f9f9c9300322b6798e051b4ac741ce9732630fe5.png)  
 ![image](https://forum.radzen.com/uploads/default/original/2X/0/01cbe7e45a5e7db0decc86ae58c1eb905e06861b.png)  
 ![image](https://forum.radzen.com/uploads/default/original/2X/0/0cd1b95ec878d3ae0afc32bd840f8222a8816b69.png)

The expression is: `${event.orderby || 'OrderDate desc'}`

The child data are retrieved using RowExpand event of the master grid - you can do the same with this invoke:

 ![image](https://forum.radzen.com/uploads/default/original/2X/4/4ebaa2cc300820f397347b798bdf0c8e90dd788c.png)  
 ![image](https://forum.radzen.com/uploads/default/original/2X/2/261e7bb975de16524aca6f1ae8dc42fd6df0ce5d.png)  
 ![image](https://forum.radzen.com/uploads/default/original/2X/c/c24309f577ad89f2e66d3a867fdd13dddf9119ba.png)

The expression is: `${event.orderby || 'ProductId desc'}`

The result:

 ![image](https://forum.radzen.com/uploads/default/original/2X/2/20c43c2452b90e54ec3d6f2b38a0a33197cd8e68.png)

Master data sorted by OrderDate descending and child data sorted by ProductId descending:

---

<div class="post-metadata">

**Author:** ![scjhnsn](https://forum.radzen.com/user_avatar/forum.radzen.com/scjhnsn/32/161_2.png) [@scjhnsn](https://forum.radzen.com/u/scjhnsn)\
**Post date:** [September 30, 2019, 2:29pm UTC](https://forum.radzen.com/t/master-detail-hierarchy-how-to-set-default-sort/1661/3 "2019-09-30T14:29:52Z")

</div>

Perfect. I hadn't noticed the RowExpand event before. Thank you.
