Hello Everyone,
Is there a way to save the sorted state of detail table?
I have 2 detail tables and AllowSorting is set to true and EditMode = Inplace. When I sort the detail table and edited one row, the detail table rebinds again and the row that I was trying to edit was not the original one.
Attached are the image for reference and code snippets for Sort Command.
Any help is greatly appreciated. Please let me know what else you need from my code.
Thanks!
Zel
Is there a way to save the sorted state of detail table?
I have 2 detail tables and AllowSorting is set to true and EditMode = Inplace. When I sort the detail table and edited one row, the detail table rebinds again and the row that I was trying to edit was not the original one.
Attached are the image for reference and code snippets for Sort Command.
protected
void
gridCPDiag_SortCommand(
object
source, GridSortCommandEventArgs e)
{
GridTableView tableView = e.Item.OwnerTableView;
if
(e.Item.OwnerTableView.Name ==
"Detail2"
&& e.SortExpression ==
"VisitFrequency"
)
{
e.Canceled =
true
;
GridSortExpression expression =
new
GridSortExpression();
expression.FieldName =
"VisitFrequency"
;
if
(tableView.SortExpressions.Count == 0 || tableView.SortExpressions[0].FieldName !=
"VisitFrequency"
)
{
expression.SortOrder = GridSortOrder.Descending;
}
else
if
(tableView.SortExpressions[0].SortOrder == GridSortOrder.Descending)
{
expression.SortOrder = GridSortOrder.Ascending;
}
else
if
(tableView.SortExpressions[0].SortOrder == GridSortOrder.Ascending)
{
expression.SortOrder = GridSortOrder.None;
}
tableView.SortExpressions.AddSortExpression(expression);
tableView.Rebind();
}
}
Any help is greatly appreciated. Please let me know what else you need from my code.
Thanks!
Zel