Monday, June 19, 2017

NavigatorX class

Updates June 21, 2017

Added Options button (red gear on the image below)

Default value is shown.  You can turn it off via setting NoOption property to .T. and this button will be hidden.  Useful in some cases where we want to restrict users to specific things only.  This Option button (right now) gives users on-the-ply capabilities to do any of these:

  • Change Interval - by default, the interval of skipping a record is one (1).  It can be set on the PEM, Others tab into greater number but then you will be stuck up on that fixed interval.  So I decided to give users the capability to change skipping of number of records at their whim, and so this.
  • Jump To Record - is requested by a subscriber after I updated them yesterday.  This allows you to specify the record number to jump stright into that.
  • Set Filter (available only when bound to Grid) - allows you to filter grid records on-the-ply. 
  • Remove Filter (available only when bound to Grid) - as the name implies, remove the filter that you set above.
After posting this, I continued on testing the class and I made further changes to the Filtering Capability as follows:

It now forces you to click on a target column first before it allows filtering. If you haven't, it will give you the message 'Click on a Column First' which cannot be selected too.


That is because it has to know on which column of the grid it should perform the filtering.  After clicking on a header, then that is the time it will show the filtering capability and mentioning as well the target field like this:


In the above image, I clicked on the header of column for Company.  Please note that when it says Set Filter to Company, that company there is the underlying field used by that column and not the column header's caption.  That allows the users to realize too where they are performing the filter.

However, I remember that not in all cases, a filtering feature is good because there might be cases where there is already a filtering implemented in a grid and if we use this class filtering capability, then it can overwrite the filter condition which you guys set by codes.  And so for cases like that, I added the NoFilter property.  Set this to .T.  and it will not show that filtering capability anymore.



Miscellaneous Effects

Miscellaneous effects for GUI can be done via playing with these properties:

1.  BackColor, BackStyle, SpecialEffect, BorderColor, and BorderWidth.

2. Hover Effect.  Cousin Glen suggested an idea to show the border of the class on Mouse Enter.  I like it so I added it here as well.  To make the effect look better (at least to my taste), I changed SpecialEffect to zero as default.  So now when you move your mouse on top of the class, it is suddenly raised and when you move away from it, it goes back flat and borderless.

Some more ideas may come to me in the future about this class or some may be suggested by others.  We will see.
====


NavigatorX is a new control class that handles record navigation like going to top, previous record, next record, and going to last record or bottom.  I was browsing for some things on the web when I saw again a Paginator (Page 4 of 24) and I said to myself, well this looks cool to be added to ssUltimate Library?  But since we are not dealing with pages inside VFP as we have grid, then it is best known to us as a navigator.

Right now, I gave it these properties:

1. Interval (default is 1).  Tells the class how many records it will attempt to skip

2. NoIndicator (default is .F.).  Sometimes if you decide to use this class on a non-sequential record, then it looks ugly to see the record indicator jumping from record to record.  Such as filtered results in a grid or a sorted one.  In which case I deem it best not to show this indicator and so you can set this property to .T. for that need and the class will adjust position and hide that label indicator

3. As for that Record Indicator, you  can control its appearance by using any of these 3 properties, i.e., FontName, FontSize and FontTop.

4. Appearance of buttons and borders are affected by SpecialEffect (default 2 or hot tracking/hover effect)

Aside from its default actions where those are intended to, you can also add your other commands in its Click event.  Just ensure that you will issue DODEFAULT() first prior to your other codes like this:

DODEFAULT()

* Do other things

For the appearance, you can further change Backstyle, Borderstyle, Bordercolor, etc.

If you bind this to a grid, clicking on grid will also update the navigator's Record Indicator bound to it

How to use this?

1.  Drag and drop onto your form
2.  On Form Init event (I prefer this event to ensure everything is already instantiated such as the needed recordsource), bind it to the controls you want refreshed.  Said controls should be bound via ControlSource or RecordSource where a simple Refresh is need to show the changes made.

This.NavigatorX1._Bind(this.grid1,'myRecordSource')


And that is it!  This is now officially part of ssUltimate Library.

2 comments:

  1. Very nice class! more power to you Sir Jun!

    ReplyDelete
    Replies
    1. Thank you Matthew. I am still adding new features to it as of this comment so I suggest that you guys check this post now and then because I am giving this more power. Cheers!

      Delete