1. John Vanleeuwe
  2. PowerBuilder
  3. Thursday, 12 July 2018 03:42 AM UTC

Hi all,

 

When you bring up the filter function for a datawindow, users can specify filter criteria.

Also there is a VERIFY button. Is it possible to have a string variable with the filter criteria and then check by powerbuilder code if this filter criteria is valid for a certain datawindow ? Is this possible ?

 

TIA

John

Accepted Answer
Michael Kramer Accepted Answer Pending Moderation
  1. Thursday, 12 July 2018 08:05 AM UTC
  2. PowerBuilder
  3. # Permalink

Hi John,

(option 1 due to René's excellent feedback)

It is possible to verify a DataWindow filter in different ways as described below.

I checked my samples using PB 2017 R2 Build 1769. My filter = "alfa = beta" to simulate typos in column names.


You can suppress user prompts using the NoUserPrompt DataWindow property. You may want to turn it back on after verifying your filter expression.

Alternatively, you can access the DataWindow buffer through a DataStore (using ShareData). DataStore behaves like prompting is turned off and cannot be turned on.

 

Option 1: Use DataWindow.NoUserPrompt

You can toggle implicit error messages using DW property = NoUserPrompt. Full code:

// Function:   ApplyFilter(datawindow adw_data, string as_filter)
// Purpose: Apply filter indicating whether filter is valid.

int filterStatus
string currentPrompt

currentPrompt = adw_data.object.datawindow.NoUserPrompt
adw_data.object.datawindow.NoUserPrompt = 'yes'
filterStatus = adw_data.SetFilter(as_filter)
adw_data.object.datawindow.NoUserPrompt = currentPrompt

if filterStatus = 1 then
adw_data.Filter( )
return true
else
return false
end if

 

Option 2: Use DataStore as Intermediate

DataStore does not support "NoUserPrompt" (I receive null object reference). Full code:

// Function:   ApplyFilter(datawindow adw_data, string as_filter): boolean
// Purpose: Apply filter indicating whether filter is valid.

datastore lds_data
blob dwContent
int filterStatus

lds_data = create datastore
dw_data.ShareData(lds_data)
filterStatus = lds_data.SetFilter(as_filter)

if filterStatus = 1 then
lds_data.Filter( )
return true
else
return false
end if

 HTH

/Michael

 

Comment
  1. René Ullrich
  2. Thursday, 12 July 2018 08:45 AM UTC
Maybe DataWindow.NoUserPrompt=no is a way to suppress error messages for #1 and #2.
  1. Helpful
  1. Michael Kramer
  2. Thursday, 12 July 2018 09:31 AM UTC
Thanks, René. I updated my answer to reflect NoUserPrompt.
  1. Helpful
There are no comments made yet.
John Vanleeuwe Accepted Answer Pending Moderation
  1. Friday, 13 July 2018 22:55 PM UTC
  2. PowerBuilder
  3. # 1

thanks Michael and Réne for your advise.

 

Kind regards

John

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.