Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Dynamic dddw filtering

437 views
Skip to first unread message

Damien Savard

unread,
Feb 4, 1998, 3:00:00 AM2/4/98
to

We currently have many datawindow columns that use the DropDownDataWindow
edit style. Some of those dddw have an active/inactive flag. The values
that have the flag set to inactive are filtered so they are not visible in
the drop down list (the users cannot add new rows we those values). When
the data is retrieved from the database we want to display the descriptive
value that comes from the dddw even if that value is mapped to an inactive
flag. The problem is that if the inactive rows are filtered from the dddw,
the descriptive values do not appear.

Any help is welcome.

--
Damien Savard
Damien...@APG.COM
APG Solutions & Technologies
70, rue Dalhousie, Suite 320
Quebec (QC)
G1K 4B2
418 692-4292 (tél.)
418 692-1369 (fax)
:o)

Ron Gallagher

unread,
Feb 4, 1998, 3:00:00 AM2/4/98
to

Damien --

Steve Benfield has a paper/presentation that has an excellent approach
to doing what you want. The basic approach for your situation would be
something like this:

1) Get handle to dddw using GetChild
dw_1.GetChild ( 'some column' , dwc_1 )
2) Retrieve the data, both active and inactive records
dwc_1.Retrieve()
3) Filter the data so that only inactive records appear in the primary
buffer
dwc_1.SetFilter ( 'status="inactive"' )
dwc_1.Filter()
4) Set the row height on all rows in the primary buffer to 0
dwc_1.SetDetailHeight ( 1 , dwc_1.RowCount() , 0 )
5) Change the filter so that all records are in the primary buffer.
dwc_1.SetFilter ( '' )
dwc_1.Filter()

Once this is done, when the user drops down the dddw, they will see all
of the active rows, but all of the inactive rows will be hidden from
view.

There is one final thing that needs to be done. If the user tabs to the
column and presses the down arrow, they will be able to scroll through
and select an inactive record. To get around this, you need to add code
to the 'other' event on the datawindow control to capture various events
on the dddw. I have the details on this at home. If you need them, let
me know via email.

HTH

Ron Gallagher, CPDP
Atlanta, GA, USA
rongal...@mindspring.com

Mark Pfeifer[TeamPS]

unread,
Feb 4, 1998, 3:00:00 AM2/4/98
to

Ron -

Do you have the sample code for the other event? I know people are
interested and it would be worthwhile to post it.

Thanks,
Mark

--
*** Are You Ready For The Web? ***
*** www.JumpStart98.com ***

Mark Pfeifer[Team Powersoft]
mpfe...@sprynet.com
www.ctpartners.com

Ron Gallagher

unread,
Feb 4, 1998, 3:00:00 AM2/4/98
to

Mark --

I have it at home. I'll pull it together and post tomorrow.

Ron Gallagher, CPDP
Atlanta, GA, USA
rongal...@mindspring.com

Ron Gallagher

unread,
Feb 4, 1998, 3:00:00 AM2/4/98
to

Mark --

I forgot that I had a copy of the app on my laptop, so here's the code.
Comments about it are at the end.

//BEGIN CODE
datawindowchild ldwc_DddwOfInterest
long ll_CurrentRowInDddw
long ll_Match
string ls_StatusInDwc

// Get a handle to the dwc that we're interested in.
This.GetChild ( 's02_xd01_spec_handle_cd' , ldwc_DddwOfInterest )

// If any of these are true, then we're done:
// 1) we're not on the column we're interested in
// 2) the event isn't for the dddw
// 3) the event id isn't for a row focus changed on the dddw.
// 4) we're filtering the data in the dddw
IF This.GetColumnName() <> 'status' OR &
IntLow ( message.longparm ) <> Handle ( ldwc_DddwOfInterest ) OR &
IntHigh ( message.longparm ) <> 2048 OR &
ib_FilteringDddw THEN
Return

// What is the current row in the dddw?
ll_CurrentRowInDddw = ldwc_DddwOfInterest.GetRow()
IF ll_CurrentRowInDddw > 0 THEN
ls_StatusInDwc = Lower ( ldwc_DddwOfInterest.GetItemString (
ll_CurrentRowInDddw , 'status' ) )
ELSE
// Save the previous dddw row in an instance variable.
il_PrevDddwRow = ll_CurrentRowInDddw
Return
END IF

// If the status from the dddw is active, then we're done.
IF ls_StatusInDwc = 'active'
// Save the previous dddw row in an instance variable.
il_PrevDddwRow = ll_CurrentRowInDddw
Return
END IF

// We got to this point, so the user selected a record that isn't active
// Go back to the last good row.
// Do we search up or down?
IF ll_CurrentRowInDddw > il_PrevDddwRow THEN
ll_Match = ldwc_DddwOfInterest.Find ( 'status = "active"' ,
ll_CurrentRowInDddw + 1 , ldwc_DddwOfInterest.RowCount() )
ELSEIF ll_CurrentRowInDddw < il_PrevDddwRow THEN
ll_Match = ldwc_DddwOfInterest.Find ( 'status = "active"' ,
ll_CurrentRowInDddw - 1 , 1 )
ELSE
Return
END IF

IF ll_Match = 0 THEN
ldwc_DddwOfInterest.SetRow ( il_PrevDddwRow )
ELSE
ldwc_DddwOfInterest.SetRow ( ll_Match )
END IF
//END CODE

Notes/Comments
1) You need to map a user event on the datawindow control (ue_command)
to the pbm_command event id
2) You will need an instance variable (il_PrevDddwRow in my sample) to
track the last row that was selected in the dddw.
3) In the rowfocuschanged event, you should reset il_PrevDddwRow to the
currently selected row in the dddw.
4) In my implementation, I was filtering the dddw everytime the user
changed rows in a list. The filtering of the dddw triggered the
rowfocuschanged event on the dddw, and consequently, the code above was
triggered. To prevent problems, I added another instance variable
(ib_FilteringDddw) that I set to TRUE before the Filter() command and
then back to FALSE immediately after the command.

HTH

Ron Gallagher, CPDP
Atlanta, GA, USA
rongal...@mindspring.com

Laurel

unread,
Feb 4, 1998, 3:00:00 AM2/4/98
to

Did you modify Steve Benfield's code quite a bit? I have a copy of the
paper, and it uses the 'other' event, and looks quite different. I'm just
wondering if he has updated his paper.
Do you find that if you have an empty column, and all the items in the
dropdown are filtered away (it appears empty), and you arrow down, or type
into the control the first time, that an item is selected? In my
implementation this sequence doesn't seem to trigger the rowfocuschanged
event on the dwc. (event = 2048 ), and I haven't been able to figure out
what event it is in order to trap it.


Ron Gallagher wrote in message <34D8E6...@mindspring.com>...

Mark Pfeifer[TeamPS]

unread,
Feb 4, 1998, 3:00:00 AM2/4/98
to

Ron -

I am sure everyone will appreciate it. They will now be able to search
Dejanews and get it on the infobase cds.

Lijun Yang

unread,
Feb 5, 1998, 3:00:00 AM2/5/98
to
> >> > Thanks,
> >> > Mark
> >> >
> >> > --
> >> > *** Are You Ready For The Web? ***
> >> > *** www.JumpStart98.com ***
> >> >
> >> > Mark Pfeifer[Team Powersoft]
> >> > mpfe...@sprynet.com
> >> > www.ctpartners.com

Laurel,

The difference is that yours is from Steve's Seminar "Advanced
Techniques of PowerBuilder Programming" and Ron's from his seminar
"Supercharging DataWindows."

Is this right?

--
Lijun

==============================================
Lijun Yang mailto:Lijun...@worldnet.att.net
mailto:Ly...@rgti.com
==============================================
"There is nothing either good or bad, but
thinking makes it so." - William Shakespeare

Ron Gallagher

unread,
Feb 5, 1998, 3:00:00 AM2/5/98
to

Laurel/Lijun --

The basis for my code was Steve's "Supercharging Datawindows"
presentation. The window that I extracted the code from would never
have a situation where no items appear in the dddw, so I can't directly
address the problem that Laurel mentions. What I can suggest is that
when you set the detail height of the 'bad' rows to 0, save the # rows
in the filter buffer. If it's 0 and the user uses the arrow keys to
select an item, reject the change.

HTH

Ron Gallagher, CPDP
Atlanta, GA, CPDP
rongal...@mindspring.com

Lijun Yang wrote:
>
> Laurel wrote:
> >
> > Did you modify Steve Benfield's code quite a bit? I have a copy of the
> > paper, and it uses the 'other' event, and looks quite different. I'm just
> > wondering if he has updated his paper.
> > Do you find that if you have an empty column, and all the items in the
> > dropdown are filtered away (it appears empty), and you arrow down, or type
> > into the control the first time, that an item is selected? In my
> > implementation this sequence doesn't seem to trigger the rowfocuschanged
> > event on the dwc. (event = 2048 ), and I haven't been able to figure out
> > what event it is in order to trap it.
> >
> > Ron Gallagher wrote in message <34D8E6...@mindspring.com>...

<<<snip>>>

Laurel

unread,
Feb 6, 1998, 3:00:00 AM2/6/98
to

Thanks for sharing this. I've implemented this functionality based on
Steve's older paper, but it looks pretty much the same. Could I ask a few
more questions?
1.

>4) In my implementation, I was filtering the dddw everytime the user
>changed rows in a list. The filtering of the dddw triggered the
>rowfocuschanged event on the dddw, and consequently, the code above was
>triggered. To prevent problems, I added another instance variable
>(ib_FilteringDddw) that I set to TRUE before the Filter() command and
>then back to FALSE immediately after the command.

I, too, am triggering filters in the rowfocus changed. How/where did
you use this instance variable? What were the problems you experienced? In
my situation, one of the problems that seems associated with this
functionality is that sometimes, when I right-mouse to add a new row (or
just add a new row - have only tried right mouse), my datawindow just blanks
out. Or, on one or two occasions, I'll get a bad row/column message, I'm
testing for currentrow > 0, GetRow() > 0, GetRow < = RowCount ....
everything I can think of. And, of course, the column name is either
correct for the dow or not - it's hard coded.

I've put the filtering logic into non-visual functions, and that seems
to exacerbate the problem. Although I get it in my hard-coded implementation
too. Currently it's auto-instantiated. I thought I'd try doing an old
fashioned create next.

2.


>// Get a handle to the dwc that we're interested in.
>This.GetChild ( 's02_xd01_spec_handle_cd' , ldwc_DddwOfInterest )

Is this really the name of the column that has the dropdown? It looks
like some sort of exotic syntax that I'm not familiar with.

3.
This isn't a question - just sharing info. I added a line to Steve's
script. The logic seems the same in your version and mine. My memory is
that it fixed a problem I was having, but I can't remember what the problem
was. And, as these things go, it could have been coincidence.

>HTH
>
>Ron Gallagher, CPDP


>Atlanta, GA, USA
>rongal...@mindspring.com
>
>Ron Gallagher wrote:
>>
>> Mark --
>>
>> I have it at home. I'll pull it together and post tomorrow.
>>

>> Ron Gallagher, CPDP

Laurel

unread,
Feb 6, 1998, 3:00:00 AM2/6/98
to

... some more questions - cont'd (sorry, I accidentally posted the message
before I was finished.)

3. This isn't a question - just sharing info. I added a line of code to
the 'other'/pbm_command event. As I remember it, it fixed a problem I was


having, but I can't remember what the problem was. And, as these things go,

it could have all been coincidence. But it looks right.

>IF ll_Match = 0 THEN
> ldwc_DddwOfInterest.SetRow ( il_PrevDddwRow )
>ELSE
> ldwc_DddwOfInterest.SetRow ( ll_Match )

il_PrevDddwRow = ll_match // Line added by me
>END IF
>//END CODE
>

4.
Finally, do you know what advantages are associated with using pbm_command
instead of 'other'? Any? Where does one read up on pbm_command? Could
only find a mention in HELP and nothing in Online Books. Do I assume
correctly that Message.Parm is getting loaded automatically?

Thanks again.

Ron Gallagher

unread,
Feb 6, 1998, 3:00:00 AM2/6/98
to

Laurel wrote:
> >4) In my implementation, I was filtering the dddw everytime the user
> >changed rows in a list. The filtering of the dddw triggered the
> >rowfocuschanged event on the dddw, and consequently, the code above was
> >triggered. To prevent problems, I added another instance variable
> >(ib_FilteringDddw) that I set to TRUE before the Filter() command and
> >then back to FALSE immediately after the command.
>
> I, too, am triggering filters in the rowfocus changed. How/where did
> you use this instance variable? What were the problems you experienced? In
> my situation, one of the problems that seems associated with this
> functionality is that sometimes, when I right-mouse to add a new row (or
> just add a new row - have only tried right mouse), my datawindow just blanks
> out. Or, on one or two occasions, I'll get a bad row/column message, I'm
> testing for currentrow > 0, GetRow() > 0, GetRow < = RowCount ....
> everything I can think of. And, of course, the column name is either
> correct for the dow or not - it's hard coded.
>
> I've put the filtering logic into non-visual functions, and that seems
> to exacerbate the problem. Although I get it in my hard-coded implementation
> too. Currently it's auto-instantiated. I thought I'd try doing an old
> fashioned create next.
>
The window that I pulled the code from presented a list of records. The
values that appeared in the dddw depended on the value in another column
on the record. So, whenever the user changed rows, I needed to do the
logic to set the row height of the 'bad' rows in the dddw to 0. When I
did the filter during this process, the pbm_command was triggered and
the parameters indicated that the row had changed on the dddw. In
reality, it didn't, but there's no way to NOT trigger a rowfocuschanged
event when you filter a dw. So, I created the instance variable
ib_FilteringDddw. It's set to TRUE right before the filter and changed
back to FALSE immediately after the filter. As far as the problems
you're having with adding records via the right mouse button, you may
want do something similar. Set the instance var to TRUE, call
InsertRow() and set the instance var back to FALSE. The variable is
declared as an instance variable at the window level. Since you've set
up a service, I would suggest declaring it as a private instance
variable with a method (of_IsFiltering()) that returns it's setting.
Wherever the logic is that responds to a rowfocuschange in the dddw, you
would check this variable to see if the service was in the middle of a
filter process.

> 2.
> >// Get a handle to the dwc that we're interested in.
> >This.GetChild ( 's02_xd01_spec_handle_cd' , ldwc_DddwOfInterest )
>
> Is this really the name of the column that has the dropdown? It looks
> like some sort of exotic syntax that I'm not familiar with.

That's the name of the column. I guess I should have sanitized the code
a little more.

> 3.


> This isn't a question - just sharing info. I added a line to Steve's
> script. The logic seems the same in your version and mine. My memory is

> that it fixed a problem I was having, but I can't remember what the problem
> was. And, as these things go, it could have been coincidence.
>
Thanks for the fix. I guess I santiized the code a little too much
<VBG>.

mark_cochran

unread,
Feb 17, 1998, 3:00:00 AM2/17/98
to

Ron Gallagher wrote in message <34D8E6...@mindspring.com>...

>Mark --
>
>I forgot that I had a copy of the app on my laptop, so here's the code.
>Comments about it are at the end.
>
>//BEGIN CODE
>datawindowchild ldwc_DddwOfInterest
>long ll_CurrentRowInDddw
>long ll_Match
>string ls_StatusInDwc
>

>// Get a handle to the dwc that we're interested in.
>This.GetChild ( 's02_xd01_spec_handle_cd' , ldwc_DddwOfInterest )
>

>// If any of these are true, then we're done:
>// 1) we're not on the column we're interested in
>// 2) the event isn't for the dddw
>// 3) the event id isn't for a row focus changed on the dddw.
>// 4) we're filtering the data in the dddw
>IF This.GetColumnName() <> 'status' OR &
> IntLow ( message.longparm ) <> Handle ( ldwc_DddwOfInterest ) OR &
> IntHigh ( message.longparm ) <> 2048 OR &
> ib_FilteringDddw THEN
>Return
>
>// What is the current row in the dddw?
>ll_CurrentRowInDddw = ldwc_DddwOfInterest.GetRow()
>IF ll_CurrentRowInDddw > 0 THEN
> ls_StatusInDwc = Lower ( ldwc_DddwOfInterest.GetItemString (
>ll_CurrentRowInDddw , 'status' ) )
>ELSE
>// Save the previous dddw row in an instance variable.
> il_PrevDddwRow = ll_CurrentRowInDddw
> Return
>END IF
>

...

Does the code you list go in the 'Other' event, or in the user event mapped
to pbm_command?


0 new messages