Monday, May 27, 2013

ssDropCalc class in a Grid, How To?



When I shared ssClasses library, I gave a sample form on most of the classes and among it is ssDropCalc (Dropdown Calculator class) showing how to run it on a default value or formula mode plus how to use it inside a grid if you wanted to.  The sample runs good, but I believe this is the second time I was asked about how to use it in a grid where my usual response is "Please check the sample form I shared for that".

But since I just got asked again about that, I decided to test myself why despite my sample, they are still
asking that.  And so I created a new form, created a cursor on its load, created a fresh grid with 2 columns, and dropped that class inside a column.  Then I made the CurrentControl of that column the class (ssdropcalc), set its Sparse property to .F. and ensure that the column's ControlSource is my target field.  Then I run the form and to my surprise, hey my users of that class really do have some problems in making it run inside the grid because what happens is I cannot see the initial values of those cells/records plus when you entered an amount on that class, all the cells of that column will have the same values.  Man.... what have I done last time to make it work? LOL!

And if I now encounter that unusual behavior, how much more are the other users of that class who are just beginning to try understanding how it works?  Anyway, I found out the reason so I decided to create this blog to serve as a guide in making it work (properly) inside a Grid.  You see, I was cramming to finish the demo forms last time so I can upload it on codeplex and can concentrate back on my real jobs in our Company that when I finish a form, I move on outright to another.  And in my rush,  I failed to mention a vital step for it to work properly inside a grid.

The Missing Link

This is needed to be done only on a grid.  The missing step which I failed to emphasize is that you need to drill down to its Calcbox Object and ensure that its ControlSource is the same as that of the Column's ControlSource.  So if the column where ssDropCalc is has a ControlSource of junk.cost, then CalcBox of that class should also have a ControlSource of junk.cost.  That is the only missing link for it to work properly on a grid.  Cheers!

No comments:

Post a Comment