PDA

View Full Version : web spinner



ivansc
7-Jun-2015, 05:24 PM
Please, test this control:

It is a numeric or date spinner (if pbDate=true).
8946
You can set the spinner with an initial value (piSpinValue).
You must set a min/max values and stop when reach them or begin again (pbCircular=true).
You can input a value (pbEditable=true).
Or set the value with the arrows in it, incrementing/decrementing the piIncrementValue.
Or with pgup/pgdown, incrementing/decrementing the piPageIncreValue.
Or with the mousewheel, incrementing/decrementing a delta set by the browser (each one has its own delta).
The value can be a decimal value (piDecimals).
The arrows can be horizontal or verticals (psHoriVer).
You can trap a changed value in the OnChanged event.
The demo doesn't do it, but you can try to work with Entry_Item file.field.

To make it work (df 18.0/18.1), in index.html write:


<!-- DataFlex Custom Controls (do not remove this line, used for automatic insertion) -->
<script src="Custom/wbspinner.js"></script>

In apphtml\custom copy wbspinner.js .
In appsrc or library copy cwbspinner.pkg .
In weborder\appsrc copy demopanels.wo .

Any input will be appreciated.
Best regards
Ivan Schoof
Don't forget to clear your browser cache

Hans van de Laar
8-Jun-2015, 02:08 AM
Hi Ivan,

Upon running from my DF 18.1 develop PC I get the following error:

C:\DataFlex 18.1 Examples\WebOrder\Programs\WebApp.exe
Ongecompileerde expressie aangeroepen 01/01/2015 ( = Attempt to run uncompiled expression)
VDF Fout#: 56 op regel: 32812.


[start] - at address 32812

ivansc
8-Jun-2015, 09:48 AM
Ongecompileerde expressie aangeroepen 01/01/2015 ( = Attempt to run uncompiled expression)
VDF Fout#: 56 op regel: 32812.


Hi Hans,
I guess, this is related with "strict evaluation mode" for strings.
Better change the sets in the oWEForm_CREACION object in DemoPanels.wo like this:


//use your own country date format (mine is dd/mm/yyyy)
Set piSpinValue to (Integer("01/01/2015"))
Set piMinValue to (Integer("01/01/1990"))
Set piMaxValue to (Integer("31/12/2030"))

regards
Ivan

Hans van de Laar
8-Jun-2015, 09:56 AM
Hi Ivan,

Thanks, but this doesn't seem to solve the problem.
Any other ideas?

ivansc
8-Jun-2015, 10:13 AM
Hi Ivan,

Thanks, but this doesn't seem to solve the problem.
Any other ideas?
maybe this way?

//use your own country date format (mine is dd/mm/yyyy)
Set piSpinValue to (Eval(Integer("01/01/2015")))
Set piMinValue to (Eval(Integer("01/01/1990")))
Set piMaxValue to (Eval(Integer("31/12/2030")))

the odd thing is that the 3 ways ( "..", (integer("..")), (eval(integer(".."))) ) works without errors here

Anders Ohrt
9-Jun-2015, 01:04 AM
Ivan,





//use your own country date format (mine is dd/mm/yyyy)
Set piSpinValue to (Integer("01/01/2015"))
Set piMinValue to (Integer("01/01/1990"))
Set piMaxValue to (Integer("31/12/2030"))



Instead of relying on changing this to the correct date format, do this:



Set piSpinValue to (Integer(01/01/2015))
Set piMinValue to (Integer(01/01/1990))
Set piMaxValue to (Integer(12/31/2030))


DF will know you mean a date, and you will not have to worry about the date format settings.

Hans van de Laar
9-Jun-2015, 02:02 AM
Thanks Anders,

That helps, but now I'm getting the same error from the piSpinValue within the oWEForm_Decimals object.

ivansc
9-Jun-2015, 09:23 AM
Ivan,
Instead of relying on changing this to the correct date format, do this:


Set piSpinValue to (Integer(01/01/2015))
Set piMinValue to (Integer(01/01/1990))
Set piMaxValue to (Integer(12/31/2030))


DF will know you mean a date, and you will not have to worry about the date format settings.

thanks Anders,
I guess that does the trick.
"strict evaluation mode" is worried about strings.


... now I'm getting the same error from the piSpinValue within the oWEForm_Decimals object.

Hans, try removing the quotes from the decimal number.

but I surprised, why the strict mode works with Hans and not with me. Really the errors are ok following what the help says

best regards
Ivan

Hans van de Laar
9-Jun-2015, 09:31 AM
Hi Ivan,

I already tried to set the spin value without qoutes, but the problem still remains
8956

ivansc
9-Jun-2015, 10:22 AM
Hi Ivan, I already tried to set the spin value without qoutes, but the problem still remains
We are advancing, now the error is in OnShow.
Your strict mode is really very strict.
We can modified this in OnShow:

WebGet psValue of oWEForm_DURACION to sval
Send OnChanged of oWEForm_DURACION (eval(Integer(sval))) (eval(Integer(sval-1)))
WebGet psValue of oWEForm_Decimals to sval
Send OnChanged of oWEForm_Decimals (eval(Number(sval))) (eval(Number(sval-1)))
But, I guess the same error you will have in OnChanged events. So, use the "eval(.." in those events.
Regards Ivan
Pd: Anders, this (integer(31/12/2015)) doesn't work for me. I get the error "Please Input a valid date". It only accepts mm/dd/yyyy. It's not very fair!!!

Evertjan Dondergoor
9-Jun-2015, 02:37 PM
Most of the time I use something like:


Property Date pdMaxSpinDate 735990 // 2015-12-31

....
Set piMaxSpinValue to (pdMaxSpinDate(Self))


That works and there can be no confusing about the format.

ivansc
9-Jun-2015, 11:56 PM
Most of the time I use something like:


Property Date pdMaxSpinDate 735990 // 2015-12-31
....
Set piMaxSpinValue to (pdMaxSpinDate(Self))


That works and there can be no confusing about the format.

Thanks evertjan
Sure, it works, only you have to find the conversion first.
but I think this (Integer(31/12/2015)) should work also, if the function uses the locale format.
Best regards
Ivan

Anders Ohrt
10-Jun-2015, 01:00 AM
Pd: Anders, this (integer(31/12/2015)) doesn't work for me. I get the error "Please Input a valid date". It only accepts mm/dd/yyyy. It's not very fair!!!

Yes, when you use this it must be a US-style date. It's fair in that it's a US date for everyone. =)

Anders Ohrt
10-Jun-2015, 01:14 AM
but I think this (Integer(31/12/2015)) should work also, if the function uses the locale format.


I think you are misunderstanding whats going on, the only way to use the locale is on strings and there is no string involved. You are defining a fixed date, and that must be done in the format DF has for dates, which is defined to be mm/dd/yyyy. Try this:



Showln 1/2/2000


The choice of using the US format is a questionable one, but it needs to be a pre-determined format.

When you put it as a string, the same string is compiled in every time, but a run time conversion is done and that can depend on the locale. That's any you should never do that, unless certain your code will never run in any other locale.

Anders Ohrt
10-Jun-2015, 01:19 AM
Most of the time I use something like:


Property Date pdMaxSpinDate 735990 // 2015-12-31


That works and there can be no confusing about the format.

If you know the DF date format (and if you forget, just check the "Date Type" in the DF help), there is no confusion. This always works:



Property Date pdMaxSpinDate 12/31/2015


Now, we don't use this normally, we have a function that takes year, month and day in and returns a date instead, so we do this:


Property Date pdMaxSpinDate (ClxDate(2015, 12, 31))

Evertjan Dondergoor
10-Jun-2015, 02:29 AM
Thanks evertjan
Sure, it works, only you have to find the conversion first.
but I think this (Integer(31/12/2015)) should work also, if the function uses the locale format.
Best regards
Ivan

You are right, it does work. But it is confusing. As a European I automatically read in dd-mm-yyyy format. If you change it to (integer(01/06/2015)) I'll read that as the 1st of June, while it will be the 6th of Jan.

The idea to use a (global) function is best, but I do work on very many projects for different customers and creating a global function is nothing always liked. Still, that's IMO the easiest and least confusing method.