Wednesday, January 24, 2018

GridX Class

Imagine yourself designing a grid and saying to yourself "it looks awesome, they will definitely love this!", then installing it on your clients' units then instead of admiration receiving complaints from some users such as "my eyes are weak, can't you make the font bigger?" or "the colors are hurting my eyes" or "can you change the order of the columns please? I want this one to come first, then this one, then...."; and some more airing of dissatisfaction.  Well, either you will go back to the drawing board and change the appearances of your grids and recompile to satisfy them or you will argue back saying "that is the way it is, live with it!".  And either one of those will dissatisfy either you or your client.

Well worry no more, here now is my latest class on ssUltimate library that deals with Grid, i.e., GridX.  This combines all the power of all my other classes for grid object (AnchorSizer, AnchorX, GridSort, GridLock, and GridSortLock) into this one class, and more.

With this class now, you are giving your users the power to manipulate further grid on runtime based on their taste.  This class retains their last selections that whatever have been set when they exit the form, the grid will be loaded back to the last arrangement and look; just the way they left it.  And the good thing is, customization is per workstation.  Different users, different tastes.

So when they started complaining, you can casually tell them "Oh, you can adjust the appearance based on your taste", with a smile.





Features
- Retains Column positions, so your users can rearrange columns via drag and drop based on how they like it
- Retains Column Widths. So your users can adjust the widths of individual columns per their satisfaction
- Hide/Unhide Columns
- Retains the last order selection and which column was ordered
- Retains which column is locked or if lock is removed

Grid Appearance
- Allows your user to toggle RecordMark and retain it
- Allows your user to toggle Theme and retain it
- Allows your user to toggle Grid Lines and retain it
- Allows your user to toggle Scrollbars and retain it
- Allows your user to toggle Highlight and retain it
- Allows your user to change grid's FontName, FontSize, FontBold and FontItalic; and retain those
- Allows your user to change grid's BackColor & ForeColor, and retain those
- Allows your user to change grid's Highlight BackColor & ForeColor, and retain those
- Allows your user to change gridlines' color and retain it
- Allows your user to adjust Header Height, and retain it
- Allows your user to adjust Row Height and retain it
- Allows them to change the font of popup, and retain it

Miscellaneous
- Gives user the ability to issue AutoFit (of all columns, if button for that is hidden)on-the-ply
- Allows your user to reset it back the way you originally set it up during design time.

Anchoring
Logical Anchor property was set here. This is to either resize the inside columns of the grid or not.  By default I set this as .F..  This one is not available during runtime so is beyond user control.

Depending on the number of columns used on a grid, you may want to use this or not.  For instance, if you have more columns than the grid can display and you plan to use the horizontal scrollbar for user to see those, then you leave this as .F..  If you have only few and you wanted that when the form (and Grid if you set its Anchor property other than zero) gets resized, to resize all columns as well, then set Anchor property of this class to .T..

Mouse Clicks
- Left click on header to sort, click on the same header to toggle order
- Right-click on header for some popup options such as locking and hiding of columns and unlocking and showing those back
- Right-click on grid cells for the popup shown above

Popups' appearance are controlled by FontName and FontSize of the class.  Default is Calibri 10.

How to Use it?
- Drop the class on form
- Double-click on target grid and on its Init event, type this: thisform.gridx1._bindgrid(this)

You can additionally set the popup font via FontName and FontSize and as mentioned, if you want the columns to be resized, change Anchor property value; on the class itself.  The rest will be handled by the class itself.

One grid, one instance of the class.  The class will latch onto which grid so it can restore it back to its last appearance.

User Satisfaction
The goal of this class is to provide user satisfaction.  Some of our users may have poor eyesight so they may want bigger fonts.  Some may be color blind and this class will enable them to adjust our grids to something that is comfortable with their eyes.  Some simply just have their own taste on fonts and colors.  In other cases, they may be running your app on a wide screen that it can be better for them to increase the fonts and adjust the columns themselves so they can see better.  There are lots of reason why giving them control over the grid appearance is better, than not.

Future Enhancements
I may add some more features in the future.  Since this has everything the aforementioned classes have, then all my future works for grids will now only be done on this one. So if you are a new subscriber and hasn't used yet any of those now legacy classes, then just use this and forget about the others mentioned above.


3 comments:

  1. This looks *very nice*. It has several features like Craig Boyd's Grid Extras. I'm betting that if I try to use them both on the same grid, it there will be some conflicts. Maybe I will take time to experiment with it one day.

    Have you ever played with Grid Extra?? This biggest this your's is missing that his has it filter on column contents. Wow, that s powerful. https://www.sweetpotatosoftware.com/blog/index.php/2008/11/25/visual-foxpro-grid-enhancements/

    ReplyDelete
  2. Hi Matt, thanks for dropping by. I did not put filtering capability here as it is included in NavigatorX class. I may, one time though, add that feature so it won't rely on using NavigatorX class for that filtering capability.

    I have seen it but never tested it yet. Craig Boyd is among the best of VFP contributors, no doubt about it.

    ReplyDelete
  3. Man I love your grid class a way to go 5 stars 🤩

    ReplyDelete