Page 1 of 1
Sorting Invoice Order Items
Posted: Tue Dec 09, 2014 6:26 am
by abradley
We pick all our orders by the invoices and we are tired of running all around the store since it does not sort the items in a useful way.
We would like to have the invoice to sort the items first by manufacturer, then by sku.
I am pretty sure I need to edit the OrderItemComparer.cs but I have no idea where to begin. Anyone got some advice on accomplishing this?
Thanks, Austin
Re: Sorting Invoice Order Items
Posted: Tue Dec 09, 2014 6:29 am
by abradley
And for that matter, a way to do this outside the source code would be much better.
Re: Sorting Invoice Order Items
Posted: Mon Dec 15, 2014 1:30 pm
by david-ebt
Austin,
If you have the source, you can make a copy of the OrderItemComparer.cs file and put it into your App_Code folder. Give it a new name and change the name of the class to something unique like MyOrderItemComparer. Then you can use that class in the ViewOrder.aspx.cs to use your sort instead of the standard one.
To do the actual sort, you'll set up the multiple compare levels like the standard OrderItemComparer code does inside your new MyOrderItemComparer class.
Hopefully that will set you on the right track.
Re: Sorting Invoice Order Items
Posted: Wed Jan 21, 2015 12:36 pm
by abradley
Thank you David! I was able to accomplish my goal and get items sorted as I like.
All my invoices are properly sorting now, except for when they are multi-page invoices. If the list of items spans more than one page, no sort occurs.
Re: Sorting Invoice Order Items
Posted: Mon Jan 26, 2015 10:37 am
by abradley
I have applied two sorts in GetItems() on the Print/Invoice.aspx.cs
Code: Select all
items.Sort(new OrderItemComparer()); // Original Sort by Able
items.Sort("Name");
items.Sort("OrderItemTypeId");
The sorts work properly on most orders except for when a order spans 2 or more pages. Then the invoice prints non-sorted.
I just debugged the page, and the method is being called and both sorts do occur before the OrderItems collection is passed to the GridView and bound. I cant find where things break yet.
Re: Sorting Invoice Order Items
Posted: Thu Feb 05, 2015 12:50 pm
by abradley
Any ideas on what would make a sort break upon a multiple page order?