Page 1 of 1

Creditor purchase - batch sorting

PostPosted: Mon Apr 03, 2017 10:48 am
by neil.interactit
Hi guys,

Happy Monday!

I've had a simple request, as part of a larger project, to provide sorting on the columns in the batch grid on the creditor purchases page. Enabling this functionality appeared easy ...

Code: Select all
        public void Setup(IJiwaForm jiwaForm, Plugin plugin)
        {
            if (!(jiwaForm is CreditorPurchases)) return;
            _form = (CreditorPurchases)jiwaForm;
            _form.grdLines.AllowSorting = true;
        }

But it doesn't have any affect. I've poked around and cannot find the alternate attribute that I should be manipulating. Any ideas?

Cheers,
Neil.

Re: Creditor purchase - batch sorting  Topic is solved

PostPosted: Mon Apr 03, 2017 2:46 pm
by Mike.Sheen
In addition to setting the AllowSorting property of the grid to be true, you also need to set the AllowSort property per column.

This is not a standard column property, but encoded in the Tag of the column header - use the following to set it for each column:

Code: Select all
foreach(FarPoint.Win.Spread.Column column in _form.grdLines.ActiveSheet.Columns)
{
   // Set the AllowSort property, as when the columns were added this was forced to be false because we didn't want you to sort because we knew it would end in tears when trying to sort with disperals.
   string tag = _form.grdLines.ActiveSheet.ColumnHeader.Cells[1, column.Index].Tag.ToString();
   tag = _form.grdLines.StoreProperty(tag, "AllowSort", "1");
   _form.grdLines.ActiveSheet.ColumnHeader.Cells[1, column.Index].Tag = tag;                  
}

Re: Creditor purchase - batch sorting

PostPosted: Tue Apr 04, 2017 3:40 pm
by neil.interactit
Thanks Mike, works a treat!

I like your comment line there! I'll pass that on to the client.

Thanks,
Neil.