Skip to content

Commit

Permalink
More sortable columns in backend product list
Browse files Browse the repository at this point in the history
  • Loading branch information
mgesing committed May 24, 2017
1 parent 1ceadf8 commit f99a507
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
Expand Up @@ -1001,20 +1001,41 @@ public ActionResult ProductList(GridCommand command, ProductListModel model)
else
query = query.OrderByDescending(x => x.Name);
}
else if (sort.Member == "Sku")
{
if (sort.SortDirection == ListSortDirection.Ascending)
query = query.OrderBy(x => x.Sku);
else
query = query.OrderByDescending(x => x.Sku);
}
else if (sort.Member == "Price")
{
if (sort.SortDirection == ListSortDirection.Ascending)
query = query.OrderBy(x => x.Price);
else
query = query.OrderByDescending(x => x.Price);
}
else if (sort.Member == "StockQuantity")
{
if (sort.SortDirection == ListSortDirection.Ascending)
query = query.OrderBy(x => x.StockQuantity);
else
query = query.OrderByDescending(x => x.StockQuantity);
}
else if (sort.Member == "CreatedOn")
{
if (sort.SortDirection == ListSortDirection.Ascending)
query = query.OrderBy(x => x.CreatedOnUtc);
else
query = query.OrderByDescending(x => x.CreatedOnUtc);
}
else if (sort.Member == "UpdatedOn")
{
if (sort.SortDirection == ListSortDirection.Ascending)
query = query.OrderBy(x => x.UpdatedOnUtc);
else
query = query.OrderByDescending(x => x.UpdatedOnUtc);
}
else
{
query = query.OrderBy(x => x.Name);
Expand Down
Expand Up @@ -158,13 +158,11 @@
columns.Bound(x => x.Name)
.Template(x => @Html.LabeledProductName(x.Id, x.Name, x.ProductTypeName, x.ProductTypeLabelHint))
.ClientTemplate(@Html.LabeledProductName("Id", "Name"));
columns.Bound(x => x.Sku)
.Sortable(false);
columns.Bound(x => x.Sku);
columns.Bound(x => x.Price)
.Format("{0:0.00}")
.RightAlign();
columns.Bound(x => x.StockQuantity)
.Sortable(false)
.Centered();
columns.Bound(x => x.LimitedToStores)
.Sortable(false)
Expand All @@ -173,8 +171,7 @@
.Hidden(Model.AvailableStores.Count <= 1)
.Centered();
columns.Bound(x => x.CreatedOn);
columns.Bound(x => x.UpdatedOn)
.Sortable(false);
columns.Bound(x => x.UpdatedOn);
columns.Bound(x => x.Published)
.Sortable(false)
.Template(item => @Html.SymbolForBool(item.Published))
Expand Down

0 comments on commit f99a507

Please sign in to comment.