Only attempt to update the sort order if the control has a model attached.
This commit is contained in:
@@ -133,10 +133,12 @@ public:
|
|||||||
// TODO: Set the column's view position.
|
// TODO: Set the column's view position.
|
||||||
}
|
}
|
||||||
|
|
||||||
// Restore the sort key and order.
|
// Restore the sort key and order if there is a valid model and sort
|
||||||
|
// criteria.
|
||||||
wxString sortColumn;
|
wxString sortColumn;
|
||||||
if ( RestoreValue(wxPERSIST_DVLC_SORT_KEY, &sortColumn) &&
|
if ( control->GetModel() &&
|
||||||
sortColumn != "" )
|
RestoreValue(wxPERSIST_DVLC_SORT_KEY, &sortColumn) &&
|
||||||
|
sortColumn != "" )
|
||||||
{
|
{
|
||||||
bool sortAsc = true;
|
bool sortAsc = true;
|
||||||
column = GetColumnByTitle(control, sortColumn);
|
column = GetColumnByTitle(control, sortColumn);
|
||||||
@@ -145,6 +147,8 @@ public:
|
|||||||
{
|
{
|
||||||
RestoreValue(wxPERSIST_DVLC_SORT_ASC, &sortAsc);
|
RestoreValue(wxPERSIST_DVLC_SORT_ASC, &sortAsc);
|
||||||
column->SetSortOrder(sortAsc);
|
column->SetSortOrder(sortAsc);
|
||||||
|
|
||||||
|
// Resort the control based on the new sort criteria.
|
||||||
control->GetModel()->Resort();
|
control->GetModel()->Resort();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user