NetTalk Central

Author Topic: Updating a Browse contents from a spinner control  (Read 5377 times)

capora56

  • Newbie
  • *
  • Posts: 12
    • View Profile
    • Email
Updating a Browse contents from a spinner control
« on: July 25, 2013, 11:22:16 AM »
Hi All

Situation : One NetWebForm procedure with a spinner and a browse hand coded. The browse is using an inmemory driver that is loaded using a query at the procedure setup to a Firebird database. The query is filtered with a PYear variable All works fine. I initialize the year in the spinner and at the first time when the page opens i see all the registers corresponding to that year. But when i modify the spinner content, the browse doesn't refresh. Please something knows in what embed point of the spinner i can read the variable used in it ?

From the Form to the browse i'm using the value queue for passing the parameters. In the form, previous to the call to the browse if i force the value of the variable it works fine, but using the spinner no

Thank you

Ruben Caporossi

kevin plummer

  • Hero Member
  • *****
  • Posts: 1195
    • View Profile
    • Production Accounting and Software Payroll
Re: Updating a Browse contents from a spinner control
« Reply #1 on: July 25, 2013, 04:31:29 PM »
you may need to store the year in the session Q. Turn on send filter to debugview and look at what your filter looks like as you use the spinner control.

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Updating a Browse contents from a spinner control
« Reply #2 on: July 25, 2013, 10:08:32 PM »
Hi Ruben,

>> The browse is using an inmemory driver that is loaded using a query at the procedure setup to a Firebird database.

you might want to put a line of debug code in there to see how often your code is running. Browse procedures are re-called a LOT during the life-cycle of the browse, so the "Procedure Setup" embed is seldom the right place to do much. Putting a line
p_web._trace('Loading from Firebird')
in your code, and then watching for that line in DebugView might go a long way to understanding what is going on.

Also, it's a good way to investigate your assumptions - like what variables are set etc - which you are using to limit the recordset from the database. My guess is you're using a value other than the SessionValue.

(Also - I'm not sure that spinners do a "new selection" - they'll do a "completed" event, but only when you tab off the field.

cheers
Bruce

capora56

  • Newbie
  • *
  • Posts: 12
    • View Profile
    • Email
Re: Updating a Browse contents from a spinner control
« Reply #3 on: July 26, 2013, 06:40:24 AM »
Thanks Kevin and Bruce.

The problem was the variables i'm using. After some changes with the Trace y verified that the content of LOC:Year is ok in the Query to the database. If I modifiy the spinner contents the correct value arrives to the query, but in this moment the problem is that the browse don't refresh in the browser. Using hand-coded programming what do I do for refreshing the browse contents ?

Navigating across the browse i noted that the registers read when i change the spinner are appended to the browse, i need to see only the filtered for this year. I tried to clean the immemory file but the problem persists ...

Thank you very much

Ruben Caporossi

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Updating a Browse contents from a spinner control
« Reply #4 on: July 28, 2013, 11:05:25 PM »
>> Using hand-coded programming what do I do for refreshing the browse contents ?

Impossible to say really without an example. Depends what you are hand-coding, and where.
Are the spinner control, and the Browse control both fields on a form?

Cheers
Bruce

capora56

  • Newbie
  • *
  • Posts: 12
    • View Profile
    • Email
Re: Updating a Browse contents from a spinner control
« Reply #5 on: July 29, 2013, 11:44:41 AM »
OK Bruce thank you for your response.

The situation is :

Spinner and LOC:Year both fields of the netwebform

In the ValidateValue Routine of LOC:Year ... Start, the following code

p_web.SetSessionValue(LYear,LOC:Year)

In the generate form 1.Start

p_web.setsessionvalue(LOC:Year,YEAR(TODAY()))
p_web.setsessionvalue('LOC:Year',YEAR(TODAY()))

If i comment the second line, the value of LOC:Year don't appear in the control in the screen. Why ? :P

In the NetWebBrowse Procedure Setup

  LYear = p_web.GetSessionValue(LOC:Year)
  Cargar_IMBuques(p_Web,LYear)

  Cargar_IMBuques is a Source procedure that contains the Query for loading the inmemory that i use in the netwebbrowse

Then in the Client-side of LOC:Year in the NetWebForm i included in the Reset List Cargar_Buque and tick Value

Cargar_IMBuques Proc

  p_web and pyear : parameters

  p_web._trace('Loading from Firebird : ' & PYear) ! Here PYear is well received when i change the value in the spinner

  DO OpenFiles

  CLEAR(SQL)
  LOC:Query = 'SELECT NROORDEN,CODPUERTO,BUQUE,VIAJE,SIGLA,TEMPORADA FROM BUQUES WHERE TEMPORADA = ' & PYear
  SQL{PROP:SQL} = LOC:Query
  IF FILEERRORCODE()
     SETCLIPBOARD(LOC:Query)
     MESSAGE('ATENCION !!! : ERROR de Lectura. ' & FILEERROR(),'ERROR',ICON:HAND,BUTTON:OK)
     MESSAGE(LOC:Query)
  ELSE
     LOOP UNTIL ACCESS:SQL.NEXT()
         IMBUQ:NROSESSIONID = p_Web.SessionID
         IMBUQ:NROORDEN = DEFORMAT(SQL:C1)
         IMBUQ:CODPUERTO = SQL:C2
         IMBUQ:BUQUE = SQL:C3
         IMBUQ:VIAJE = SQL:C4
         IMBUQ:SIGLA = SQL:C5
         IMBUQ:TEMPORADA = DEFORMAT(SQL:C6)           
         Access:IMBUQUES.Insert()
     END
  END

  DO CloseFiles

Cheers

Ruben

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Updating a Browse contents from a spinner control
« Reply #6 on: July 29, 2013, 09:41:10 PM »
>> p_web.setsessionvalue(LOC:Year,YEAR(TODAY()))

this does nothing (well nothing useful).

>> p_web.setsessionvalue('LOC:Year',YEAR(TODAY()))

this is the correct syntax for SetSessionValue - the first parameter should be the variable name in quotes.

so this is wrong;
p_web.SetSessionValue(LYear,LOC:Year)
and this
LYear = p_web.GetSessionValue(LOC:Year)
should be
LYear = p_web.GetSessionValue('LOC:Year')

cheers
Bruce

capora56

  • Newbie
  • *
  • Posts: 12
    • View Profile
    • Email
Re: Updating a Browse contents from a spinner control
« Reply #7 on: July 30, 2013, 08:00:06 AM »
OK Bruce

After fixing the errors you told me, nothing happens, the browse don't refresh after changing the year in the spinner. Other thing i noted is if i press the last button after changing then year in the spinner, the browse refresh but when i press again it works wrong. I see the contents for the 2013 year at startup but then the refresh don't work.

Really i don't know what to do ...

Ruben

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Updating a Browse contents from a spinner control
« Reply #8 on: August 15, 2013, 01:18:41 AM »
[ I removed some of the reminders in this thread, so the thread doesn't get too long ]

Hi Ruben,

Ok, I've had a chance to look through the example, and there are a couple suggestions I have;

a) Bear in mind that a spin control, like any other control, only generates a "accepted" event when you tab off it. You don't get an "accepted" event as the number scrolls. It's possible to make the spinner "immediate" in the future, but I'm not sure that's desirable here. Anyway, as at the time of writing, you need to tab off the control to "complete" it. One technique to prompt a user to do this is to put an "other" button on the form, next to the spinner. The button doesn't have to do anything, but pressing it implicitly "completes" the spinner control.

b) You are calling Cargar_IMBuques from Muestro_Buqyes in the wrong place. You have it in the "Procedure Setup" embed. This will get called for every single event on the browse. Rather move it to the "Browse Take Event - Before Generate" embed point.

c) In Cargar_IMBuques you are continually adding to the IMBUQUES table, but you are not removing the "earlier entries for the sesison". So the browse itself will grow and grow (or at least the data in the table will grow and grow.) Make a procedure that removes "all the entries in IMBUQUES for this session" and call it from the begining of the Cargar_IMBuques procedure. Also call this procedure from the WebHandler, NotifyDeleteSession method. That way the table will be tidied up when the session ends.

That should get you going for now.

cheers
Bruce




capora56

  • Newbie
  • *
  • Posts: 12
    • View Profile
    • Email
Re: Updating a Browse contents from a spinner control
« Reply #9 on: August 15, 2013, 03:51:05 AM »
Thanks Bruce

I'll try all the things you say

Cheers

Ruben