PC SOFT

FOROS PROFESIONALES
WINDEVWEBDEV y WINDEV Mobile

Inicio → WEBDEV 2024 → How to manipulate check box by programming ?
How to manipulate check box by programming ?
Iniciado por Stef, 06,ago. 2014 13:33 - 12 respuestas
Publicado el 06,agosto 2014 - 13:33
Hi all,

(Using WebDev 19.)

I am facing a challenge as I am creating a WebDev variant of an existing WinDev application.
In WinDev manipulation of Check boxes with multiple options is a piece of cake: you can hide/unhide, gray out, enable/disable one or more options of a check box at will during runtime. In the project I am working on the availability of certain check box options depends on choices made within other check boxes and/or the values selected in combo boxes.

So far so good but it seems that simulating this behavior in WebDev is virtually impossible. There are almost no check box properties available in browsercode, which is the only way to go to have fast screen updates.
As an alternative I tried using servercode with AJAX enabled, which works fine as long as there are no commands in the server procedure that conflict with AJAX. And there's the catch: many commands do conflict and I cannot isolate them in separate procedures. I can fiddle with the check box item caption using AJAX enabled server code, but this leaves me with quite a bit of serverprocedures not able to run under AJAX and thus not updating the screen. Due to the nature of the application a full refresh of the screen simply takes too long.

I am stuck with a trade off:
- either the application is too slow but correctly displays the option availability
- or either the application is smooth and fast but the available options are not correctly updated for the user

So the questions is: does anyone have any tricks in manipulating Option fields (and also Combo boxes for that matter because the issue is similar there).

Thanks
Publicado el 06,agosto 2014 - 14:49
Hi Stefan

You can use JS to disable checkboxes item in browser code:
JSProperty("_PAGE_."+CHX_CheckBoxName..Alias+"[1]","disabled") = True

Best regards

--
Fabrice Harari
International WinDev, WebDev and WinDev mobile Consulting

NEW: WXShowroom.com is available: Show your projects!
More information on http://www.fabriceharari.com


On 8/6/2014 5:33 AM, Stef wrote:
Hi all,

(Using WebDev 19.)

I am facing a challenge as I am creating a WebDev variant of an existing
WinDev application. In WinDev manipulation of Check boxes with multiple
options is a piece of cake: you can hide/unhide, gray out,
enable/disable one or more options of a check box at will during
runtime. In the project I am working on the availability of certain
check box options depends on choices made within other check boxes
and/or the values selected in combo boxes.

So far so good but it seems that simulating this behavior in WebDev is
virtually impossible. There are almost no check box properties available
in browsercode, which is the only way to go to have fast screen updates.
As an alternative I tried using servercode with AJAX enabled, which
works fine as long as there are no commands in the server procedure that
conflict with AJAX. And there's the catch: many commands do conflict and
I cannot isolate them in separate procedures. I can fiddle with the
check box item caption using AJAX enabled server code, but this leaves
me with quite a bit of serverprocedures not able to run under AJAX and
thus not updating the screen. Due to the nature of the application a
full refresh of the screen simply takes too long.

I am stuck with a trade off: - either the application is too slow but
correctly displays the option availability
- or either the application is smooth and fast but the available options
are not correctly updated for the user

So the questions is: does anyone have any tricks in manipulating Option
fields (and also Combo boxes for that matter because the issue is
similar there).

Thanks
Publicado el 07,agosto 2014 - 08:53
Thank you Fabrice !
Today I am working on another non-WebDev/WinDev project at another clients location so I cannot test this now.
But it sure looks promising, I will update tomorrow as soon as I'm back working on this particular project.
Thanks again, I really appreciate your help.
Publicado el 08,agosto 2014 - 10:01
Hi Fabrice,

I just can't get this to work.
For example, if I want to disable the 3rd out of 4 listed options of a checkbox named 'Borstelprofiel_03' (alias is A270) on a tab 'TAB_Bestellingen' of the current page called 'Bestellingen_01', following your instructions I think I should use the following syntax:

JSProperty("PAGE_Bestellingen_01."+Borstelprofiel_03..Alias+"[3]","disabled")=True
Syntax is correct according to Webdev, but nothing seems to happen though, the 3rd option can still be checked or unchecked.

Also
JSProperty("PAGE_Bestellingen_01.TAB_Bestellingen"+Borstelprofiel_03..Alias+"[3]","disabled")=True
has no effect.

I also tried "grayed" instead of "disabled" but also this has no effect at all.

What am I doing wrong ?
Publicado el 08,agosto 2014 - 13:05
Hi Stef

no, you should always keep the "_PAGE_." (this is a JS element)

Best regards

--
Fabrice Harari
International WinDev, WebDev and WinDev mobile Consulting

NEW: WXShowroom.com is available: Show your projects!
More information on http://www.fabriceharari.com


On 8/8/2014 2:01 AM, Stef wrote:
Hi Fabrice,

I just can't get this to work.
For example, if I want to disable the 3rd out of 4 listed options of a
checkbox named 'Borstelprofiel_03' (alias is A270) on a tab
'TAB_Bestellingen' of the current page called 'Bestellingen_01',
following your instructions I think I should use the following syntax:

JSProperty("PAGE_Bestellingen_01."+Borstelprofiel_03..Alias+"[3]","disabled")=True

Syntax is correct according to Webdev, but nothing seems to happen
though, the 3rd option can still be checked or unchecked.

Also
JSProperty("PAGE_Bestellingen_01.TAB_Bestellingen"+Borstelprofiel_03..Alias+"[3]","disabled")=True

has no effect.

I also tried "grayed" instead of "disabled" but also this has no effect
at all.

What am I doing wrong ?
Publicado el 08,agosto 2014 - 20:08
Hi Fabrice,:

I also tried these syntaxes earlier today:
JSProperty("_PAGE_."+Borstelprofiel_03..Alias+"[3]","disabled")=True
JSProperty("PAGE_."+Borstelprofiel_03..Alias+"[3]","disabled")=True

Unfortunately no luck with these either.
I must be missing something here ?
Publicado el 11,agosto 2014 - 13:07
Hi again

at this point, I can only tell you the following:
- it works for me in IE/FF/and chrome
- Without seeing your code and specially WHERE you put this, it's going
to be hard to find out what's wrong on your side. Your call to this may
be masked by something else

Best regards


--
Fabrice Harari
International WinDev, WebDev and WinDev mobile Consulting

NEW: WXShowroom.com is available: Show your projects!
More information on http://www.fabriceharari.com
Publicado el 12,agosto 2014 - 08:20
Hi Fabrice,

I am running this under IE9 (9.0.8112.16421 to be exact) on a Vista machine.
The code is in a browser procedure "Exit with modification" of a radio button box called 'Typeschuifdeur_03' with 4 options.
Depending on which option is selected by the user I need to enable/disable several other options of a radio button box 'Borstelprofiel_03' with also 4 options. I emptied all server code in the 'Whenever modified of...' server procedure of the first radio button box 'Typeschuifdeur' except for an info line just to check whether the browser code did run because I cannot debug browser code or to be more specific I know of no means to debug browser code. In short, the code is accepted by Webdev and it is run, but it has no effect on the option box: all options are still selectable.

The browsercode is pretty straightforward:
SWITCH TypeSchuifdeur_03
CASE 1 :
Borstelprofiel_03..Visible = True // works fine
JSProperty("_PAGE_."+Borstelprofiel_03..Alias+"[1]","disabled") = False // no effect
JSProperty("_PAGE_."+Borstelprofiel_03..Alias+"[2]","disabled") = False // no effect
JSProperty("_PAGE_."+Borstelprofiel_03..Alias+"[3]","disabled") = True // no effect
JSProperty("_PAGE_."+Borstelprofiel_03..Alias+"[4]","disabled") = True // no effect
CASE 2:
... similar code ...
END

Hope this helps ?
Publicado el 12,agosto 2014 - 11:48
Hi Stef

yes, it DOES help...

I think that your problem is:


>>I emptied all server code in
> the 'Whenever modified of...' server procedure of the first radio button
> box 'Typeschuifdeur' except for an info line just to check whether the
> browser code did run because I cannot debug browser code or to be more
> specific I know of no means to debug browser code.
<<

You are doing an info in server code... This means that the page is
refreshed, and because the server side doesn't know that you disabled
the checkboxes on the browser side, they are refreshed in their original
state.

Futhermore, because you are using IE, you are not seeing the browser
changes before the page is refreshed, while in other (better?) browsers
like chrom or FF you would see the checkbox disabled THEN reenabled when
the page is refreshed.

This kind of code (ie things done on the browser side) means that you
cannot have ANY PAGE LEVEL REFRESH coming from the server (ie no info,
no pagerefresh, or anything of the kind or you will loose your changes.

So make sure that all server code calledin that process is AJAX enabled,
so that you are not refreshing the whole page.

Best regards

--
Fabrice Harari
International WinDev, WebDev and WinDev mobile Consulting

NEW: WXShowroom.com is available: Show your projects!
More information on http://www.fabriceharari.com


On 8/12/2014 12:20 AM, Stef wrote:
Hi Fabrice,

I am running this under IE9 (9.0.8112.16421 to be exact) on a Vista
machine.
The code is in a browser procedure "Exit with modification" of a radio
button box called 'Typeschuifdeur_03' with 4 options.
Depending on which option is selected by the user I need to
enable/disable several other options of a radio button box
'Borstelprofiel_03' with also 4 options. I emptied all server code in
the 'Whenever modified of...' server procedure of the first radio button
box 'Typeschuifdeur' except for an info line just to check whether the
browser code did run because I cannot debug browser code or to be more
specific I know of no means to debug browser code. In short, the code is
accepted by Webdev and it is run, but it has no effect on the option
box: all options are still selectable.

The browsercode is pretty straightforward:
SWITCH TypeSchuifdeur_03
CASE 1 : Borstelprofiel_03..Visible = True // works fine

JSProperty("_PAGE_."+Borstelprofiel_03..Alias+"[1]","disabled") = False
// no effect
JSProperty("_PAGE_."+Borstelprofiel_03..Alias+"[2]","disabled")
= False // no effect

JSProperty("_PAGE_."+Borstelprofiel_03..Alias+"[3]","disabled") = True
// no effect
JSProperty("_PAGE_."+Borstelprofiel_03..Alias+"[4]","disabled")
= True // no effect
CASE 2:
... similar code ...
END

Hope this helps ?
Publicado el 13,agosto 2014 - 15:50
Hi Fabrice,

This does shed light on the issue, however there was one more thing to be kept in mind before this actually worked:
At first, I set the info line (which was the only code line in the servercode part) to comment using // and then ran the test... still nothing.
So even a server procedure with only comment lines (and for that matter even one with nothing in it except for an empty line) will be sent to the server who does absolutely nothing with it but still refreshes the page.

But after all your suggestion does works, thank you for your effort !

I am still faced with a huge limitation though. This does imply I cannot afford to run any servercode (or at least no code that does not support AJAX) after I changed the available options using the JSProperty command.
Which is virtually unfeasible because lots of other controls on the same page have to be manipulated, changed,... and a lot of them simply requiere the server to recalculate and transmit updated information.

But nevertheless, thank you, this was really educational.

Kind regards
Stefan
Publicado el 13,agosto 2014 - 16:02
I just realized that all of this could have been avoided if there was a server command that would disable certain options out of an option list. However I already tried that extensively but unsuccesfully in an earlier stage, which led me to the original question.

But unfortunately
Option_X[1]..state=grayed
is not supported by WebDev.
Option_X..state=grayed
will work but then of course all options become unavailabe which is not the desired effect.

And again the entire page would have to be updated in case non-ajax supported commands are included in the serverprocedure.

So here I am with 2 additional questions:
-Is there any server code that disables single options of an option field ?
-Am I correct to presume that there will be no alternative but to accept the slow page updates in order to get the available options displayed correctly at all times ?

Thanks again
Publicado el 13,agosto 2014 - 16:14
Hi Stef

Actually, it's not "virtually unfeasible", it's just quite complex ...
If I knew how to gray a checkbox item, you have to realize it's because
I had to use it, and I did use it in a VERY complex case, with tons of
controls all managed either from the browser side or in ajax...

it does require a good amount of imagination, though :-)

Best regards

--
Fabrice Harari
International WinDev, WebDev and WinDev mobile Consulting

NEW: WXShowroom.com is available: Show your projects!
More information on http://www.fabriceharari.com


On 8/13/2014 7:50 AM, Stef wrote:
Hi Fabrice,

This does shed light on the issue, however there was one more thing to
be kept in mind before this actually worked:
At first, I set the info line (which was the only code line in the
servercode part) to comment using // and then ran the test... still
nothing.
So even a server procedure with only comment lines (and for that matter
even one with nothing in it except for an empty line) will be sent to
the server who does absolutely nothing with it but still refreshes the
page.

But after all your suggestion does works, thank you for your effort !

I am still faced with a huge limitation though. This does imply I cannot
afford to run any servercode (or at least no code that does not support
AJAX) after I changed the available options using the JSProperty command.
Which is virtually unfeasible because lots of other controls on the same
page have to be manipulated, changed,... and a lot of them simply
requiere the server to recalculate and transmit updated information.

But nevertheless, thank you, this was really educational.

Kind regards
Stefan
Publicado el 13,agosto 2014 - 20:47
Hi Stef

> -Is there any server code that disables single options of an option field ?
AFAIK, there is not

-Am I correct to presume that there will be no alternative but to accept
the slow page updates in order to get the available options displayed
correctly at all times ?

No, you are not... Any web UI where you want fast response (such as you
dare describing) HAS to be fully AJAX... So it's not the checkboxes that
is the problem, it is your assumption that you can get a fast refresh
WITHOUT ajax.
And of course, at that point, doing some things can become a
challenge... However, you can have a fully functional UI and a very
complex one with AJAX, secondary pages displayed in iframes, and a
little JS code

Best regards

--
Fabrice Harari
International WinDev, WebDev and WinDev mobile Consulting

NEW: WXShowroom.com is available: Show your projects!
More information on http://www.fabriceharari.com

> Thanks again