By default, the master grid doesn't save its detail grid's state after operations with data, such as sorting, grouping, filtering. Thus, it should be saved manually.
To implement this feature, handle the ClientLayout event and store layout data on the server side. In this example unique session values are used.
A corresponding session value is cleared if a row is collapsed.