Page 1 of 1

Sales Order batch printing/emailing sortable grid

PostPosted: Wed Feb 05, 2020 3:36 pm
by DannyC
Any reason why the batch printing/emailing grid can't be sorted?
I have a client who really needs it.

Re: Sales Order batch printing/emailing sortable grid

PostPosted: Wed Feb 05, 2020 3:42 pm
by Scott.Pearce
Sorting is a grid-only/UI thing. The underlying collection is the order in which the actions are processed when the "Process" button is clicked.

To change the order in which the actions are processed, you need to modify the underlying stored procedure that spits back rows when you click the "Go" button. The stored proc used is defined at System Settings->System Configuration->Invoicing->StoredProcForGettingActionsInSOBatchPrinting

Re: Sales Order batch printing/emailing sortable grid

PostPosted: Wed Feb 05, 2020 3:45 pm
by Mike.Sheen
Scott.Pearce wrote:Sorting is a grid-only/UI thing. The underlying collection is the order in which the actions are processed when the "Process" button is clicked.

To change the order in which the actions are processed, you need to modify the underlying stored procedure that spits back rows when you click the "Go" button. The stored proc used is defined at System Settings->System Configuration->Invoicing->StoredProcForGettingActionsInSOBatchPrinting


You could also allow sorting on the grid, hook into the grid sorted event and in there renumber the itemNo property of each item in the backing collection which would then cause the print / email to be performed in the order the user sorted by.

And while you're at it, add the row header and allow row-drag and dropping to reorder.

Should only take a few minutes. Get cracking, Scott.

Re: Sales Order batch printing/emailing sortable grid

PostPosted: Wed Feb 05, 2020 3:52 pm
by Scott.Pearce
On it.

Logged as https://service.jiwa.com.au/browse/DEV-8052 and will also include in next SR.

Re: Sales Order batch printing/emailing sortable grid

PostPosted: Wed Feb 05, 2020 3:52 pm
by Mike.Sheen
Scott.Pearce wrote:On it.

Logged as https://service.jiwa.com.au/browse/DEV-8052 and will also include in next SR.


I meant as a plugin!

Re: Sales Order batch printing/emailing sortable grid

PostPosted: Wed Feb 05, 2020 4:19 pm
by DannyC
Well either would be good.
A plugin for 7.2.1 for now, until the next SR is released.

Luv ya work fellas.

Re: Sales Order batch printing/emailing sortable grid

PostPosted: Wed Feb 05, 2020 8:56 pm
by SBarnes
Actually a change to the Jiwa Grid so that there was a flag passed in for making it sortable would be good on AddColumn, just so long as it didn't break existing code.

Re: Sales Order batch printing/emailing sortable grid

PostPosted: Thu Feb 06, 2020 6:54 pm
by Mike.Sheen
SBarnes wrote:Actually a change to the Jiwa Grid so that there was a flag passed in for making it sortable would be good on AddColumn, just so long as it didn't break existing code.


I think we already do have an AllowSort parameter passed to AddColumn - it's just this form must have not set that to true when adding the columns - probably because when the user sorted the grid it didn't change the order it was actually printed / emailed in. In all other places in Jiwa where we let the user sort a grid, we don't renumber the ItemNo property of each item of the backing collection because we didn't want just UI sorting to result in the business logic going and setting the ItemNo property dirtying all items in the collection resulting in every item being updated on save... but in this case it seems reasonable to have a UI sort doing exactly that.

Re: Sales Order batch printing/emailing sortable grid

PostPosted: Thu Feb 06, 2020 7:05 pm
by SBarnes
Ah now I get the idea behind your original post on this it shouldn't be that hard to do it in a plugin after having a look at how the grid was setup to have the column ids and know which column is which and then hook up to the sort event and access the business logic object in a form plugin

Re: Sales Order batch printing/emailing sortable grid

PostPosted: Fri Feb 07, 2020 11:08 am
by SBarnes
Ok this became little more difficult than I thought in doing this for the service release it may be worth noting the following(apologies if any of this is obvious)

1. Turning sorting on wasn't that difficult on the grid, however it might be nice if the grid had an alter column method that took the same params as add column

2. Because repainting the entire grid can be slow when there a lots of candidates its better to just up date the line number on the grid and stay away from the backing store until the user is ready to process.

3. Only update the candidates collection when the user presses the process button. However is appears DisplayActions on the form only iterates over the collection and doesn't take into account the line number, so I had to using a working collection to get them in order and clear and refill the candidates.