NetTalk Central

Author Topic: Filter does not work on two browse on same "page"  (Read 8986 times)

Johan van Zyl

  • Full Member
  • ***
  • Posts: 180
  • jvz
    • View Profile
    • Email
Filter does not work on two browse on same "page"
« on: December 16, 2011, 05:21:45 AM »
Hi

LOG table with and alias ALOG
BrowseStaffRequest
and a child on the browse i.e.
BrowseStaffAvailable

when you click on a row in StaffRequest all available staff rows must be shown in StaffAvailable


Filters
This works:
ALOG:TaskType = ''StaffAvailability'' and ALOG:HasBeenCompleted = 0 and ALOG:HasBeenCancelled = 0'

This does not
'ALOG:AvailableFromDate <=  p_web.GetSessionValue(''LOG:DateRequired'')  AND ALOG:AvailableToDate =>  p_web.GetSessionValue(''LOG:DateRequiredTo'') AND ALOG:TaskType = ''StaffAvailability'' and ALOG:HasBeenCompleted = 0 and ALOG:HasBeenCancelled = 0'

Where exactly must I put the filer? Under Default Filter of BrowseStaffAvailable

Thx!
Johan van Zyl
Clarion 6.3 9058/C8 Gold/SQL/NetTalk WebServer

Rene Simons

  • Hero Member
  • *****
  • Posts: 650
    • View Profile
Re: Filter does not work on two browse on same "page"
« Reply #1 on: December 16, 2011, 06:10:20 AM »
Hi Johan,

The problem is the fact that you put the p_web stuff as text in the filter expression.
The filtering works the way: If the filter is wrong the filter will be ignored.

You have to concatenate the p_web.gsv values and the pext parts and create a string that looks like a proper expression.

Try This

'ALOG:AvailableFromDate <= ' &  p_web.GSV('LOG:DateRequired') & ' AND ALOG:AvailableToDate >= ' &  p_web.GSV('LOG:DateRequiredTo') & ' AND ALOG:TaskType = <39>StaffAvailability<39> and ALOG:HasBeenCompleted = 0 and ALOG:HasBeenCancelled = 0' 

This should all fit in one line of code. You can use F10 when you type the filter in the filter field.
Mind the quotes and spaces.
Also replace p_web.GetSessionValue with p_web.gsv   (less typing, more overview, less mistakes)

Cheers,
Rene
Rene Simons
NT14.14

Johan van Zyl

  • Full Member
  • ***
  • Posts: 180
  • jvz
    • View Profile
    • Email
Re: Filter does not work on two browse on same "page"
« Reply #2 on: December 16, 2011, 06:57:30 AM »
Thx Rene!

Still cannot get it to work though - see 2 attached files.

If you click on ASCOT PARK there must be 1 row for StaffAvailable - that still does not display.
if you click on blank Hospital Name there must be none.
Johan van Zyl
Clarion 6.3 9058/C8 Gold/SQL/NetTalk WebServer

Rene Simons

  • Hero Member
  • *****
  • Posts: 650
    • View Profile
Re: Filter does not work on two browse on same "page"
« Reply #3 on: December 16, 2011, 08:01:55 AM »
Hi Johan,

Make the filter case insensitive. See the bold part in the filter string

'ALOG:AvailableFromDate <= ' &  p_web.GSV('LOG:DateRequired') & ' AND ALOG:AvailableToDate >= ' &  p_web.GSV('LOG:DateRequiredTo') & ' AND UPPER(ALOG:TaskType) = <39>STAFFAVAILABILITY<39> and ALOG:HasBeenCompleted = 0 and ALOG:HasBeenCancelled = 0'

Also

Go into the source and find where the filter is set. Look for  LOC:FilterWas
In the first embed AFTER setting the filter, type: message(loc:filterwas) and run the app.

You'll see in the message what he filter string looks like.

Post it here if you can't figure it out.

Cheers,
Rene

P.s.
Bruce's NetTalk book has a very helpful chapter about filtering.
Rene Simons
NT14.14

Johan van Zyl

  • Full Member
  • ***
  • Posts: 180
  • jvz
    • View Profile
    • Email
Re: Filter does not work on two browse on same "page"
« Reply #4 on: December 17, 2011, 01:49:05 AM »
Cannot upload PNG
"The upload folder is full. Please try a smaller file and/or contact an administrator." ????

It is a very small PNG file - and how do I contact the administrator?

Hi

Still no luck.

Current filter:
'ALOG:AvailableFromDate <= ' &  p_web.GSV('LOG:DateRequired') & ' AND ALOG:AvailableToDate >= ' &  p_web.GSV('LOG:DateRequiredTo') & ' AND ALOG:TaskType = <39>StaffAvailability<39> and ALOG:HasBeenCompleted = 0 and ALOG:HasBeenCancelled = 0'

Message shows something like this:
ALOG:AvailableFromDate <=  AND ALOG:AvailableToDate >=  AND ALOG:TaskType = 'StaffAvailability and ALOG:HasBeenCompleted = 0 and ALOG:HasBeenCancelled = 0
(I cannot post the PNG of message here)

This on its own works -  ALOG:TaskType = <39>StaffAvailability<39> - no need for UPPER in this case.

See attached for the filter in message.
The values from p_web.GSV does not show?

Source from StaffAvailableBrowse
ThisView{prop:order} = p_web.CleanFilter(ThisView,clip(loc:vorder))
      loc:FilterWas = 'ALOG:AvailableFromDate <= ' &  p_web.GSV('LOG:DateRequired') & ' AND ALOG:AvailableToDate >= ' &  p_web.GSV('LOG:DateRequiredTo') & ' AND ALOG:TaskType = <39>StaffAvailability<39> and ALOG:HasBeenCompleted = 0 and ALOG:HasBeenCancelled = 0'
  ThisView{prop:Filter} = loc:FilterWas
  Loc:LocatorValue = p_web.GetLocatorValue(Loc:LocatorType,'StaffAvailable',Net:Both)
  ! Start of "Browse Filter"
  ! [Priority 5000]
  !message(loc:filterwas)  ! display message here?
  ! End of "Browse Filter"
  loc:FilterWas = ThisView{prop:filter}
  if loc:filterwas <> p_web.GetSessionValue('StaffAvailable_Filter')
    p_web.SetSessionValue('StaffAvailable_FirstValue','')
    p_web.SetSessionValue('StaffAvailable_Filter',loc:filterwas)
  end
  p_web._SetView(ThisView,ALog,ALOG:pk_log_lognumber,loc:PageRows,'StaffAvailable',left(Loc:LocateField),loc:FileLoading,loc:LocatorType,clip(loc:LocatorValue),Loc:SortDirection,loc:ViewOptions,Loc:FillBack,Loc:Direction,loc:NextDisabled,loc:PreviousDisabled,Loc:LocatorCase)
  ! Start of "After SetView"
  ! [Priority 5000]
    message(loc:filterwas)  ! or display message here?

Maybe  p_web.SSV('LOG:DateRequired')  p_web.SSV('LOG:DateRequiredTo') must be done in StaffRequestBrowse?
When you click on row in StaffRequestBrowse the filtered rows must be shown in StaffAvailableBrowse
when you first land on screen with 2 browses from menu choice will the hilited row (1st row by default) in StaffRequestBrowse trigger the filter - or only after selecting a certain row by clicking on it?

Thx!





« Last Edit: December 17, 2011, 04:40:52 AM by Johan van Zyl »
Johan van Zyl
Clarion 6.3 9058/C8 Gold/SQL/NetTalk WebServer

Rene Simons

  • Hero Member
  • *****
  • Posts: 650
    • View Profile
Re: Filter does not work on two browse on same "page"
« Reply #5 on: December 17, 2011, 01:34:54 PM »
Hi Johan,

I see no session value for LOG:DateRequired and LOG:DateRequiredTo.
Probably you assume that sessionvars are set automaticly.
As far as I know  only primary file fields are set automaticly  as session vars. The rest is up to you.
I figure that once youo get your session vars sorted out, the filterwillwork fine.

Cheers
Rene
Rene Simons
NT14.14

Johan van Zyl

  • Full Member
  • ***
  • Posts: 180
  • jvz
    • View Profile
    • Email
Re: Filter does not work on two browse on same "page"
« Reply #6 on: December 19, 2011, 07:06:56 AM »
Hi Rene/Bruce/Everyone

Still no luck

Here is filter from web app (F10 on filter field)
'ALOG:AvailableFromDate <= ' &  p_web.GSV('LOG:DateRequiredFrom') & ' AND ALOG:AvailableToDate >= ' &  p_web.GSV('LOG:DateRequiredTo') & ' AND ALOG:TaskType = <39>StaffAvailability<39> and ALOG:HasBeenCompleted = 0 and ALOG:HasBeenCancelled = 0'
Which does not work - no rows are shown.
(NOTE: I have renamed the field to LOG:DateRequiredFrom)

This is the filter in the Windows version of the app
ALOG:AvailableFromDate <= LOG:DateRequiredFrom and ALOG:AvailableToDate => LOG:DateRequiredTo AND ALOG:TaskType = 'StaffAvailability' and ALOG:HasBeenCompleted = 0 and ALOG:HasBeenCancelled = 0  
and it works as expected.

therefore the
p_web.GSV('LOG:DateRequiredFrom')  and  p_web.GSV('LOG:DateRequiredTo') does not work
So "obviously" p_web.GSV must be done somewhere - for these 2?
Also- Must I set Hotfields anywhere?




[attachment deleted by admin]
« Last Edit: December 19, 2011, 07:21:05 AM by Johan van Zyl »
Johan van Zyl
Clarion 6.3 9058/C8 Gold/SQL/NetTalk WebServer

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Filter does not work on two browse on same "page"
« Reply #7 on: December 19, 2011, 07:28:28 AM »
>> p_web.GSV('LOG:DateRequiredFrom')  and  p_web.GSV('LOG:DateRequiredTo') does not work

more accurately, the method call to GSV is working, but the two fields do not contain any values.

>> So "obviously" p_web.GSV must be done somewhere - for these 2?

I think you mean p_web.SSV (SetSessionValue) must be done somewhere for these two.
I would agree with that.
Are you setting them somewhere?

cheers
Bruce

Johan van Zyl

  • Full Member
  • ***
  • Posts: 180
  • jvz
    • View Profile
    • Email
Re: Filter does not work on two browse on same "page"
« Reply #8 on: December 19, 2011, 07:35:17 AM »
Oops - yes I meant SSV!

Where do I set them?

Tried a few places - nothing works.

[attachment deleted by admin]
« Last Edit: December 19, 2011, 07:38:37 AM by Johan van Zyl »
Johan van Zyl
Clarion 6.3 9058/C8 Gold/SQL/NetTalk WebServer

Rene Simons

  • Hero Member
  • *****
  • Posts: 650
    • View Profile
Re: Filter does not work on two browse on same "page"
« Reply #9 on: December 19, 2011, 08:38:46 AM »
"Where do I set them??"
I  don't know.
As soon as you read the record concerned. you do a p_web.ssv('LOC:DateReuiredFrom',LOC:DateRequiredFrom) and the other one.

In case you only know the uniqque key for LOC, you might want to fetch that record first.

Rene
Rene Simons
NT14.14

Johan van Zyl

  • Full Member
  • ***
  • Posts: 180
  • jvz
    • View Profile
    • Email
Re: Filter does not work on two browse on same "page"
« Reply #10 on: December 19, 2011, 09:22:32 AM »
I have now put this in embed point
AfterBrowseRowClicked(StaffRequest) 
p_web.ssv('LOG:DateRequiredFrom',LOG:DateRequiredFrom)
   p_web.ssv('LOG:DateRequiredTo',LOG:DateRequiredTo)

Still does not work - at least it now shows ZEROs instead off nothing.

I don'y know what this means.
"In case you only know the uniqque key for LOC, you might want to fetch that record first."

I have a browse StaffRequest (LOG table) and a child called StaffAvailable (The alias of LOG called ALOG)
When I click on a row in StaffRequest it must filter StaffAvailable
Johan van Zyl
Clarion 6.3 9058/C8 Gold/SQL/NetTalk WebServer

Rene Simons

  • Hero Member
  • *****
  • Posts: 650
    • View Profile
Re: Filter does not work on two browse on same "page"
« Reply #11 on: December 19, 2011, 11:09:27 AM »
Hi Johan,

The way I do it, and I don't know if it's the right way but it works:

In the routine where LOC:FilterWas is assigned, before the assigning of the filter string,  embed:

LOC:<your key field> = p_web.gsv('LOC:<your key field')

p_web.ssv('LOC:RequiredDateFrom',0)
p_web.ssv('LOC:RequiredDateTo',0)

if ~access:LOC.fetch(<your key>)
   p_web.ssv('LOC:RequiredDateFrom',LOC:RequiredDateFrom)
   p_web.ssv('LOC:RequiredDateTo',LOC:RequiredDateTo)
end

See if this works. Make sure LOC is in the "other" file section.

Maybe Bruce knows a better solution.   

Cheers,
Rene
Rene Simons
NT14.14

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Filter does not work on two browse on same "page"
« Reply #12 on: December 19, 2011, 09:53:16 PM »
embedding in the browse is a bad idea, because
a) the browse is not active when the form loads
b) while the "on click" will run, it'll do so asyncronously with the form loading, and the order is not guarenteed.

Also - your SSV will not work because the "clicked on record" is not loaded into the record buffer.

So embed in the form, probably the top of the GenerateForm routine is best.
you need to
open the parent file
load the parent record (the Unique ID fields are in the Value queue)
assign the session values
close the file.

Cheers
Bruce


Rene Simons

  • Hero Member
  • *****
  • Posts: 650
    • View Profile
Re: Filter does not work on two browse on same "page"
« Reply #13 on: December 19, 2011, 09:59:18 PM »
:-)
Rene Simons
NT14.14

Johan van Zyl

  • Full Member
  • ***
  • Posts: 180
  • jvz
    • View Profile
    • Email
Re: Filter does not work on two browse on same "page"
« Reply #14 on: December 19, 2011, 11:29:14 PM »
This works - sort of!

In StaffAvailableBrowse

!  %BeforeBrowseOptions

       LOG:LogNumber = p_web.gsv('LOG:LogNumber')
   
       p_web.ssv('LOC:RequiredDateFrom',0)
       p_web.ssv('LOC:RequiredDateTo',0)
   
        if ~access:LOG.fetch(LOG:pk_log_lognumber)
           p_web.ssv('LOG:DateRequiredFrom',LOG:DateRequiredFrom)
           p_web.ssv('LOG:DateRequiredTo',LOG:DateRequiredTo)
        end
       ! it seems to require a NT version of ThisWindow.Reset(1)
       ! for now double-clicking on the row works
       HELP!
     
       Thx so far Bruce and Renee!
Johan van Zyl
Clarion 6.3 9058/C8 Gold/SQL/NetTalk WebServer