Page 1 of 1

saving/restoring columns on custom form

PostPosted: Wed Sep 09, 2020 9:34 am
by pricerc
I've got a custom inventory import form based on a JiwaGrid, which is working well, except for user-customization of the column order. Which doesn't work at all, which is harshing my mellow.

is there a quick and easy way to turn this on?

Re: saving/restoring columns on custom form

PostPosted: Wed Sep 09, 2020 1:05 pm
by Mike.Sheen
For the customised columns to work for you automatically, 3 requirements need to be met
  • The form needs to Implement or inherit from a class that implements IJiwaForm
  • The form should be created by the Form Factory
  • In your code, after adding columns to the grid you need to invoke the SetupComplete() method

I *think* that's all you need to do. Let us know if you think you meet the above and it still isn't working.

Re: saving/restoring columns on custom form

PostPosted: Wed Sep 09, 2020 6:13 pm
by SBarnes
That is all as I have just realised from this post that custom forms I've done allow custom columns, but I do have a question as an aside, is there a way in code to set the starting next line on enter column?

Re: saving/restoring columns on custom form

PostPosted: Thu Sep 10, 2020 9:23 am
by pricerc
Mike.Sheen wrote:For the customised columns to work for you automatically, 3 requirements need to be met
  • The form needs to Implement or inherit from a class that implements IJiwaForm
  • The form should be created by the Form Factory
  • In your code, after adding columns to the grid you need to invoke the SetupComplete() method

I *think* that's all you need to do. Let us know if you think you meet the above and it still isn't working.


Hmmm. So I have all that.
I'm inheriting from JiwaApplication.ProcessAction.UserInterface. Which implements IJiwaForm
The form is being opened from a menu item
I call SetupComplete on my grid after adding all my columns, and just before adding the event handlers for button click, cell click, cell changed, and sort.

So now that I'm off-site and looking a bit closer, it seems it is partly working. I'm not sure what I changed since the problem was reported to me, but originally, I was getting an error (Object reference not set to an instance of an object) when trying to customize the layout. Now it will now allow me to make changes.

I did have all my columns defaulting to a width of 0, which I've now changed.

The only problem now is that it seems my 'defaults' are saved somewhere with all my columns having a zero width, so if I 'turn off' custom columns (or reset to defaults in the customization dialog), they are all invisible. Where do I reset that?

Re: saving/restoring columns on custom form

PostPosted: Thu Sep 10, 2020 9:46 am
by Scott.Pearce
Custom column info is stored in SY_UserProfile with an IDKey of "CustomXML" and a Section consisting of the full control name.

Standard column info is not stored in the database. When you call myGrid.SetupComplete(), myGrid.ActiveSheet.GenerateXMLDefinition() is called, which places all the column info, including widths, into a property named StandardColumnXML. Turning off custom columns pushes StandardColumnXML values (including column widths) back into the grid.

So, I cannot see how you are getting the behaviour you are describing, considering you claim your grid setup code is doing this:

1. Adding columns and providing a width
2. Calling myGrid.SetupComplete() *after* adding all the columns

Happy to do a debug if you want to provide me with some code, through PM or otherwise.

Re: saving/restoring columns on custom form

PostPosted: Thu Sep 10, 2020 9:53 am
by Scott.Pearce
SBarnes wrote:is there a way in code to set the starting next line on enter column?


Please excuse the Visual Basic code:

Code: Select all
With myGrid.ActiveSheet.ColumnHeader.Cells(1, IndexOfMyColumn)
    .Tag = myGrid.StoreProperty(.Tag, "NextLineOnEnter", "1")
    .Tag = myGrid.StoreProperty(.Tag, "TabOrder", "005") '005 meaning column 5 on the next line.
End With

Re: saving/restoring columns on custom form

PostPosted: Thu Sep 10, 2020 11:19 am
by pricerc
Thanks.

So at first glance, it looks like I have all the right bits in the right places, but then have something weird going on.

I'll need to come back to this puzzle a bit later when I've got time to walk it through. Unfortunately, I have higher priorities for the rest of the day.

This isn't a high-priority problem, since the whole point of the plugin is that the columns match the output from some other system and they are pasting in the data from the clipboard, so they don't really have a need to rearrange it (for now). So at the moment, it's more my OCD that's keeping me looking at it than anything else.