saving/restoring columns on custom form

Discussions relating to plugin development, and the Jiwa API.

saving/restoring columns on custom form

Postby pricerc » Wed Sep 09, 2020 9:34 am

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?
/Ryan

ERP Consultant,
Advanced ERP Limited, NZ
https://aerp.co.nz
User avatar
pricerc
Senpai
Senpai
 
Posts: 504
Joined: Mon Aug 10, 2009 12:22 pm
Location: Auckland, NZ
Topics Solved: 20

Re: saving/restoring columns on custom form

Postby Mike.Sheen » Wed Sep 09, 2020 1:05 pm

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.
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756

Re: saving/restoring columns on custom form

Postby SBarnes » Wed Sep 09, 2020 6:13 pm

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?
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1618
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: saving/restoring columns on custom form

Postby pricerc » Thu Sep 10, 2020 9:23 am

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?
/Ryan

ERP Consultant,
Advanced ERP Limited, NZ
https://aerp.co.nz
User avatar
pricerc
Senpai
Senpai
 
Posts: 504
Joined: Mon Aug 10, 2009 12:22 pm
Location: Auckland, NZ
Topics Solved: 20

Re: saving/restoring columns on custom form

Postby Scott.Pearce » Thu Sep 10, 2020 9:46 am

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.
Scott Pearce
Senior Analyst/Programmer
Jiwa Financials
User avatar
Scott.Pearce
Senpai
Senpai
 
Posts: 742
Joined: Tue Feb 12, 2008 11:27 am
Location: New South Wales, Australia
Topics Solved: 221

Re: saving/restoring columns on custom form

Postby Scott.Pearce » Thu Sep 10, 2020 9:53 am

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
Scott Pearce
Senior Analyst/Programmer
Jiwa Financials
User avatar
Scott.Pearce
Senpai
Senpai
 
Posts: 742
Joined: Tue Feb 12, 2008 11:27 am
Location: New South Wales, Australia
Topics Solved: 221

Re: saving/restoring columns on custom form

Postby pricerc » Thu Sep 10, 2020 11:19 am

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.
/Ryan

ERP Consultant,
Advanced ERP Limited, NZ
https://aerp.co.nz
User avatar
pricerc
Senpai
Senpai
 
Posts: 504
Joined: Mon Aug 10, 2009 12:22 pm
Location: Auckland, NZ
Topics Solved: 20


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 5 guests

cron