Solved

Sort order on existing mobile grid

  • 20 July 2022
  • 4 replies
  • 202 views

Userlevel 4
Badge +1

Hello, 

Does anyone know if it is possible to change the sort order of an existing grid in a mobile screen?
In this case I’d like to change the sort order of the grid on the Pick, Pack and Ship mobile screen (SO302020). 
The screen is shown below. The items are ordered by line number, but I’d like to reorder them by location code. 

Is this possible?


Thanks

Steve

icon

Best answer by Dioris Aguilar 2 August 2022, 01:25

View original

4 replies

Userlevel 5
Badge +2

@stephenward03 It’s possible, you would need to override the existing Picked view defined in the PickPackShip graph extension:
 

public
SelectFrom<SOShipLineSplit>
.InnerJoin<SOShipLine>.On<SOShipLineSplit.FK.ShipmentLine>
.OrderBy<SOShipLineSplit.shipmentNbr.Asc, SOShipLineSplit.isUnassigned.Desc, SOShipLineSplit.locationID.Asc>
.View Picked;

In the code above, LineNbr was replaced by LocationID.

Once you do this, the records in the mobile will follow the new sorting rule.

Userlevel 4
Badge +1

Thanks for your suggestion. Overriding the view looks like the correct approach, I got bogged down with the mobile app was looking for options there. I’ve overridden the view and changed the sort order, and this works. However, it has led to a further problem, all the filtering has been lost from the view. Now the grid shows every shipment in the database.

Looking at the source code for this view. I see the following view definition:

public
SelectFrom<SOShipLineSplit>
.InnerJoin<SOShipLine>.On<SOShipLineSplit.FK.ShipmentLine>
.OrderBy<SOShipLineSplit.shipmentNbr.Asc, SOShipLineSplit.isUnassigned.Desc, SOShipLineSplit.lineNbr.Asc>
.View Picked;

followed by an enumerable definition:

protected virtual IEnumerable picked()
{
var assignedOnly =
SelectFrom<SOShipLineSplit>.
InnerJoin<SOShipLine>.On<SOShipLineSplit.FK.ShipmentLine>.
InnerJoin<INLocation>.On<SOShipLineSplit.locationID.IsEqual<INLocation.locationID>>.
Where<SOShipLineSplit.shipmentNbr.IsEqual<Header.refNbr.FromCurrent>>.
View.Select(Base)
.AsEnumerable()
.Cast<PXResult<SOShipLineSplit, SOShipLine, INLocation>>();

IEnumerable<PXResult<SOShipLineSplit, SOShipLine, INLocation>> splits;
if (HeaderView.Current.Mode.IsIn(Modes.Pick, Modes.Free) || HeaderView.Current.Mode.IsIn(Modes.Pack, Modes.Free) && NoPick)
{
var unassignedOnly =
SelectFrom<Unassigned.SOShipLineSplit>.
InnerJoin<SOShipLine>.On<Unassigned.SOShipLineSplit.FK.ShipmentLine>.
InnerJoin<INLocation>.On<Unassigned.SOShipLineSplit.locationID.IsEqual<INLocation.locationID>>.
Where<Unassigned.SOShipLineSplit.shipmentNbr.IsEqual<Header.refNbr.FromCurrent>>.
View.Select(Base).AsEnumerable()
.Cast<PXResult<Unassigned.SOShipLineSplit, SOShipLine, INLocation>>()
.Select(r => new PXResult<SOShipLineSplit, SOShipLine, INLocation>(MakeAssigned(r), r, r));

splits = assignedOnly.Concat(unassignedOnly);
}
else
splits = assignedOnly;

(var picked, var nonpicked) = splits.DisuniteBy(s => s.GetItem<SOShipLineSplit>().PickedQty >= s.GetItem<SOShipLineSplit>().Qty);

var delegateResult = new PXDelegateResult { IsResultSorted = true };

delegateResult.AddRange(
nonpicked
.OrderBy(
r => Setup.Current.ShipmentLocationOrdering == SOPickPackShipSetup.shipmentLocationOrdering.Pick
? r.GetItem<INLocation>().PickPriority
: r.GetItem<INLocation>().PathPriority)
.ThenBy(r => r.GetItem<SOShipLineSplit>().IsUnassigned == false) // unassigned first
.ThenBy(r => r.GetItem<SOShipLineSplit>().InventoryID)
.ThenBy(r => r.GetItem<SOShipLineSplit>().LotSerialNbr));

delegateResult.AddRange(
picked
.OrderByDescending(
r => Setup.Current.ShipmentLocationOrdering == SOPickPackShipSetup.shipmentLocationOrdering.Pick
? r.GetItem<INLocation>().PickPriority
: r.GetItem<INLocation>().PathPriority)
.ThenByDescending(r => r.GetItem<SOShipLineSplit>().InventoryID)
.ThenByDescending(r => r.GetItem<SOShipLineSplit>().LotSerialNbr));

return delegateResult;
}

I think this method is applying filter and sorting too. 
I read somewhere that the method with the same name is the view will also need to be overridden is the view is overridden. Does this sound correct? I started trying to override the method but I’m struggling to fix various errors/find types and values. Want to ensure I’m following the correct route before spending more time trying to get it working. 

Thanks

Steve

Userlevel 5
Badge +2

@stephenward03 The enumerable definition is what’s known as the view delegate that allows you to do some extra processing to the records.
Did you try to override that view delegate calling the base method?

Userlevel 4
Badge +1

Thanks Dioris, 
Yes, in this case it is the view delegate which is setting the sorting on the view, not the view itself. The view has it’s own OrderBy statement which confused me for a while because this OrderBy statement is replaced by the sorting in the view delegate. By changing the sorting on the view delegate I was able to change the sorting which appeared in the UI.
Thanks
Steve

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved