1. James Medick
  2. PowerBuilder
  3. Friday, 25 January 2019 19:00 PM UTC

Is there a way to filter out some selection options from a dddw at run time?  Example, starting with a list of 10 items, and then only showing 7 of those based upon the user's actions.  PB 12.8, Windows 10.

Accepted Answer
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Thursday, 31 January 2019 20:57 PM UTC
  2. PowerBuilder
  3. # Permalink

Hi James;

  I took a few DW's from your PBL that you posted and recreated a working filter on the DDDW column (see attached).

Note: In the future, if you are having difficulties with a design, coding, debugging, support ticket, etc extra effort- you can now open a "Premium" ticket and one of our Appeon staff will be assigned to you to wrestle these to the ground (as best we can).

FYI: https://www.appeon.com/premium-support.html

HTH

Regards ... Chris

Attachments (1)
Comment
There are no comments made yet.
James Medick Accepted Answer Pending Moderation
  1. Thursday, 31 January 2019 21:38 PM UTC
  2. PowerBuilder
  3. # 1

Thanks Chris.

I was just using the wrong column, create the child on the column name, set the filter using the dddw index.

Sorry for the trouble

Comment
  1. Chris Pollach @Appeon
  2. Thursday, 31 January 2019 21:49 PM UTC
No worries. However, what works for me in these cases is "more coffee" - LOL!

Happy PB'ing! ;-)
  1. Helpful
There are no comments made yet.
Roland Smith Accepted Answer Pending Moderation
  1. Thursday, 31 January 2019 21:22 PM UTC
  2. PowerBuilder
  3. # 2

One thing to remember about the DDDW, it is only retrieved once so the same data is used on every row of the main DataWindow. If you filter the DDDW on one row, it will be filtered on all rows.

This won't be a problem if you only have one row.

Comment
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Thursday, 31 January 2019 20:24 PM UTC
  2. PowerBuilder
  3. # 3

Looks like there are missing ancestor objects in the example source code that you posted.

Comment
There are no comments made yet.
James Medick Accepted Answer Pending Moderation
  1. Thursday, 31 January 2019 19:30 PM UTC
  2. PowerBuilder
  3. # 4

I'm using PB 2017 R3, build 1858 on Windows 10.  The code is simply:

DataWindowChild child1
li_rtc = dw_detail.GetChild( "mbo_status", child1)
ls_filter = "mbo_status = 'Open'"
li_rtc_set_filter = child1.setfilter(ls_filter)
li_rtc_filter = child1.Filter()

Source is attached.

Thanks

Attachments (1)
Comment
There are no comments made yet.
James Medick Accepted Answer Pending Moderation
  1. Thursday, 31 January 2019 17:02 PM UTC
  2. PowerBuilder
  3. # 5

So as a test, I created a new datawindow that contains two columns, one of which is mbo_status which has a dddw control placed on it.  No matter what I do, I cannot set the filter on the dddw.  I'm using GetChild as shown in the code previously.  The SetFilter value of -1 equates to "If no DataWindow object has been assigned to the DataWindow or DataStore, SetFilter returns –1".  The only error I ever receive is "Catalog tables could not be created and are not available for use", upon startup but I don't know why this would be an issue.

The return code on creating the child is 1, success.  The return code on setting the filter for the child is always -1 failure (unless its "" which passes but does nothing).  I can set a filter on any other column without a problem, just not on the child.

 

Comment
  1. Chris Pollach @Appeon
  2. Thursday, 31 January 2019 18:17 PM UTC
Hi James;

If you can post the source for your test app - maybe we can spot something or at least validate that it actually works in PB2017 as I see that you seem to be using PB 12.6 (from your initial question post).

Regards ... Chris
  1. Helpful
There are no comments made yet.
James Medick Accepted Answer Pending Moderation
  1. Wednesday, 30 January 2019 19:46 PM UTC
  2. PowerBuilder
  3. # 6

Thanks for the reply.

No matter what value I place in the filter (ls_filter), the SetFilter statement always returns a -1.  If I set the filter to "", null, then no error.  I must be referencing the wrong column

Comment
There are no comments made yet.
David Vasconcelos Accepted Answer Pending Moderation
  1. Wednesday, 30 January 2019 19:18 PM UTC
  2. PowerBuilder
  3. # 7

James, looking at the code you posted all I can see is

ls_filter = "mbo_status = Open"

If mbo_status is a string column then the word Open needs to be wrapped in quotes.

I.e

ls_filter = "mbo_status = 'Open'"

 

Other thing I noticed (maybe an issue) if you are getting a display value for mbo_status that tells me it may contain a code.  If that is true then you would need to use that code and not the display value for your filter.

I.e.  if mbo_status was "O" and display value was "Open" you would need to filter

ls_filter = "mbo_status = 'O'"

and not

ls_filter = "mbo_status = 'Open'"

 

Hope this helps..(and not completely missing the point)

Dave V.

 

 

Comment
There are no comments made yet.
James Medick Accepted Answer Pending Moderation
  1. Wednesday, 30 January 2019 18:58 PM UTC
  2. PowerBuilder
  3. # 8

Just can't get this to work.  I know I'm doing some obvious thing wrong but can't find it.  Code looks like this:


DataWindowChild child1
li_rtc = dw_detail.GetChild( "mbo_status", child1)
ls_status = dw_detail.describe("evaluate('lookupdisplay(mbo_status)',1)") //Just to see what's there
ls_filter = "mbo_status = Open"
li_rtc_set_filter = child1.setFilter(ls_filter)
li_rtc_filter = child1.Filter()

I always get a -1 on the SetFilter, so something not right here.

child1 is a dddw on the dw_detail object (master / detail window). 

The column in dw_detail that the dddw is on is "mbo_status". 

The display column in the dddw is "status_condition".

I'm running this code out of the RowFocusChanged event of the dw_master just to see if I can get it to work.  All of the values display correctly in the debugger.

The overall idea is that if the selected row in the master (dw_master) has the value of "Open", then I want to set the value of the mbo_status column (which is in the detail dw_detail and which has a dddw control on it), to only display "Open or Closed". 

The dddw is a two column window, key - numeric, and display value - character.

Comment
There are no comments made yet.
Matthew Balent Accepted Answer Pending Moderation
  1. Monday, 28 January 2019 19:42 PM UTC
  2. PowerBuilder
  3. # 9

Remember that when dealing with the ItemChanged event on a datawindow the entry (data) made is not 'accepted' into the control until after the event had successfully completed.  You may need to create a 'post itemchanged' event which is posted if a change is made to one of the columns which affects your dddw entries.  In this new event you would do your filtering and etc...

Comment
There are no comments made yet.
John Fauss Accepted Answer Pending Moderation
  1. Monday, 28 January 2019 03:12 AM UTC
  2. PowerBuilder
  3. # 10

James -

It would be helpful to see the code. If you can supply a small, example app that demonstrates the problem, we should be able to provide you with some help. Without it we are limited to making educated guesses.

Comment
  1. Chris Pollach @Appeon
  2. Monday, 28 January 2019 15:09 PM UTC
Hi John;

I agree .. Jame's code would be very helpful here now. This technique is pretty straightforward - so it must be something trivial that he is - or - is not doing.

Regards ... Chris
  1. Helpful
There are no comments made yet.
James Medick Accepted Answer Pending Moderation
  1. Friday, 25 January 2019 21:54 PM UTC
  2. PowerBuilder
  3. # 11

Not sure how EditChanged event helps.  The ItemChanged event works fine, just can't get the filter to work on the dddw.  Editchanged seems like it would be overkill and inefficient - but if it works?  Everything is working in ItemChanged now, just no filter success.

Comment
There are no comments made yet.
James Medick Accepted Answer Pending Moderation
  1. Friday, 25 January 2019 21:07 PM UTC
  2. PowerBuilder
  3. # 12

Can't seem to get the dddw contents to filter.  I have four items, when focus changes (itemchanged event) I try to filter the dddw to only allow 1 selection option from then on.  I use Getchild to get the dddw, then filter on the child.  All codes are ok, I just never get the filter to work.  Initially, I use the Describe("Evaluate('lookupdisplay(colmun_name)... to get the text of the dddw selected item.  The value is "Open", I then set the filter to "Closed", or "column_name = 'Closed'", neither work.

 

Comment
  1. Chris Pollach @Appeon
  2. Friday, 25 January 2019 21:38 PM UTC
Hi James;

FWIW: Use the "EditChanged" event instead. ;-)

HTH

Regards ... Chris
  1. Helpful
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Friday, 25 January 2019 19:42 PM UTC
  2. PowerBuilder
  3. # 13

Hi James;

     Yes, just use GetChild() command to locate the pointer to the DDDW in question and then follow through with that DDDW Pointer using the SetFilter() & Filter () commands.

HTH

Regards ... Chris

 

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.