On Sep 29, 2007, at 6:30 PM, <lalong1 (at) bellsouth .DOT net> <lalong1@bellsouth.net> wrote:
> If the user has made > changes and just wants to switch between Kilo/Lbs and we had to > requery a > bizobj every time then the user would be forced to update or cancel > changes.
I think that this is where you misunderstood my suggestion. There is no need to requery; instead, define your SQL in the bizobj so that there is an additional column to be used for display; it is this display column that is the DataField for the grid's column. Let's say that the weights are stored in kilos, and you want to change them to display in imperial units, formatted like "13 lbs. 4 oz.". When the user toggles to imperial, the form calls:
self.bizobj.showImperial() self.grid.update()
The bizobj has a 'showImperial()' method that works something like this:
self.replace("displayfield", "=self.formatImperial('kiloweight')")
This would replace the contents of 'displayfield' with the formatted text you desire (assuming you've already written the 'formatImperial ()' bizobj method). The update forces the grid to grab this new value of displayfield for the weight column.
BTW, going over this stuff I found a copy-paste bug in the dDataSet.replace() method. So this exercise has helped me, too!
> Further, using the get/setValue, I have been able to program the > form to > display 10 lbs 5 oz, if the user types in 10.5 in the qtytomove > cell (a nice > shortcut if I do say so myself).
The grid already has a method called afterCellEdit(row, col) that allows you to do this sort of post-processing when the user edits a value. In this case, not only could you change the displayed text, you could also pass the value to the bizobj so that the updatable field, which is in kilos, is updated with the equivalent metric value.
-- Ed Leafe -- http://leafe.com -- http://dabodev.com
©2007 Ed Leafe |