1. Avory Rose Pastoral
  2. PowerBuilder
  3. Thursday, 2 September 2021 16:15 PM UTC

Hello,

 

I'm having trouble with .setfilter function. Well, I manage to make it work. What seems to be my problem is that I have a dropdown list and a datawindow. Everytime I clicked or picked on that dropdown the value will filter in my datawindow and I have that "ALL" item on my dropdown list when I picked that supposed to be it will go back to the original data in the datawindow which didn't filter anything but it's showing nothing. I know I'm missing some logic on my script. Any help would be very much appreciated. Thank you so much!

Here is what I have. I attached the image also for your reference.

 

string s_colname, s_criteria, s_null, s_dtefrom, s_dteto, ls_datefrom, ls_dateto, ls_filter, s_sysrefno
datetime dt_from,dt_to
long l_count, l_row
int i_sort


datawindowchild dwc_child, dwc_station

s_colname = this.getcolumnname()
this.accepttext()
setnull(s_null)

 

Choose case s_colname

case "station"
this.accepttext()
is_station = this.getitemstring(1,'station')

 

// in this part what im trying to do is to reload the datawindow without the filter.
if is_station = '' or isnull(is_station) or is_station = '000' then
messagbox("",is_station)dw_activate_spots.retrieve(is_sysrefno)

//dw_activate_spots.reset()
return
end if

this.getchild('station',dwc_station)
s_criteria = is_station
dw_activate_spots.SetFilter("ordd_stncde = '"+ s_criteria +" '")
dw_activate_spots.filter()

// "ordd_stncde = '"+ is_station +" '"+ " AND " + "ordd_teledte >= Date('" + String(idt_from, "mm/dd/yyyy") + "')" + " AND " + " ordd_teledte <= Date('" + String(idt_to, "mm/dd/yyyy") + "')"

end choose


Attachments (1)
Avory Rose Pastoral Accepted Answer Pending Moderation
  1. Thursday, 2 September 2021 23:39 PM UTC
  2. PowerBuilder
  3. # 1

Hi Thanks for your help, got it working! Another question how about after I set dw.setfilter("") I want to make a filter on that list? If you see on my attached screenshot I also have date filter. So when I picked "ALL" in dropdown list I still want to filter the list by dates. Thank you!

Comment
  1. John Fauss
  2. Friday, 3 September 2021 01:37 AM UTC
The SetFilter function DEFINES the filter criteria, but takes NOo action. If you desire, you can issue 50 SetFilter calls in a row and there will be no discernible effect on what row are or are not filtered. Also, you don't have to clear the existing filter criteria before setting new criteria. The Filter function is what actually performs the filtering, and it does so on ALL of the rows in the DataWindow's/DataStore's Primary data buffer and any rows currently filtered (those residing in the Filtered data buffer).



If you have not yet done so, I suggest you review the PB Help topics on the SetFilter and Filter DataWindow functions and learn all you can about them.
  1. Helpful 1
There are no comments made yet.
Ronnie Po Accepted Answer Pending Moderation
  1. Thursday, 2 September 2021 16:51 PM UTC
  2. PowerBuilder
  3. # 2

Hi Avory,

When the user chooses "ALL" in the dddw:

dw_activate_spots.setFilter("")

dw_activate_spots.filter()

 

Comment
There are no comments made yet.
Brad Mettee Accepted Answer Pending Moderation
  1. Thursday, 2 September 2021 16:50 PM UTC
  2. PowerBuilder
  3. # 3

You need to clear the filter, otherwise retrieve will just use the existing filter and leave you with no data showing.

Try it like this

// in this part what im trying to do is to reload the datawindow without the filter.
if is_station = '' or isnull(is_station) or is_station = '000' then
messagbox("",is_station)
dw_activate_spots.SetiFilter("")
dw_activate_spots.Filter()  // or, if you need to refresh the data, do .retrieve(is_sysrefno) instead of .filter()

//dw_activate_spots.reset()
return
end if

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.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.