PC SOFT

FOROS PROFESIONALES
WINDEVWEBDEV y WINDEV Mobile

Inicio → WEBDEV 2024 → [WB23] Change Scrollbar
[WB23] Change Scrollbar
Iniciado por ARV, 31,ago. 2018 19:49 - 10 respuestas
Miembro registrado
498 mensajes
Popularité : +8 (8 votes)
Publicado el 31,agosto 2018 - 19:49
Hi

I have an edit and I want to change the scrollbar position to be always the last when I execute a special code, I search but I didn't find anything.

is it possible?
Thanks

--
Best Regards
Jose
Miembro registrado
17 mensajes
Popularité : +1 (1 vote)
Publicado el 05,septiembre 2018 - 11:58
Hi José,

You can try a javascipt function:
function scrolltoEnd(sAlias) {
sAlias.scrollTop = sAlias..scrollHeight;
}
Where sAlias is the alias of the edit control.
(not tested)

Kind regards,
Piet
Miembro registrado
498 mensajes
Popularité : +8 (8 votes)
Publicado el 07,septiembre 2018 - 19:59
Hi

Ok I will tested but How do I execute javascript code?

I search this:
https://help.windev.com/en-US/…

but I'm not too sure about it, I need the alias of the page? or something?
sorry could you tell me?

Thanks for the reply btw!

--
Best Regards
ARV
Miembro registrado
17 mensajes
Popularité : +1 (1 vote)
Publicado el 08,septiembre 2018 - 11:00
Hi Jose,

There are several ways but in this case I recommend creating a new local browser procedure.
In the code of this procedure click on the "WL" text on the top left of the code window, the tab will color blue and you will be able to enter a Javascript function there. Just empty the entire code window and copy/paste the code below. Make sure the name of the Webdev procedure is the same as the name of the function
function scrolltoEnd(sAlias) {
var el=document.getElementById(sAlias);
el.scrollTop = el.scrollHeight;
}
(I have added document.getElementById(sAlias) to the javascript code to have a better chance that it will work)
You can call the function from browser code, for instance in the "Return from AJAX process" section of a button or link click code.
scrolltoEnd(edt_NoName1..Alias)

Remember that any non-AJAX call to the server will reset the scrollbar.

Kind regards,
Piet
Miembro registrado
498 mensajes
Popularité : +8 (8 votes)
Publicado el 08,septiembre 2018 - 17:00
Hi Piet

Oh! thanks I already did everything you said
(the local browser procedure it's like on windev mobile when you create a global procedure and you can change the Wlanguage to Java code wow I didn't know Webdev could do something like that)

Well the bad part it's like I put everything but when I execute my ajax mode on a button nothing happends, maybe I could doing something wrong?

here's some screenshots:
Browser procedure:




Button code:




I don't execute anything when I'm clicking on my button, before that I execute some code to add info on my edit I want to set the scrollbar to the end, with some concat and html code but when I'm finish I do the button code and doesn't work.

Thanks for the help and explanation! it's a big help!

--
Best Regards
ARV
Mensaje modificado, 08,septiembre 2018 - 17:03
Miembro registrado
17 mensajes
Popularité : +1 (1 vote)
Publicado el 08,septiembre 2018 - 19:40
Hi Jose,

Strange, I tested this in WB 23 and it worked.
I assume EDT_Chat is a multiline edit control and the content has more lines than the displayed number of lines so the scrollbar is visible?
You could put an alert() in the function to check if anything is happening e.g. alert(el.scrollHeight); between line 2 and 3.

Kind regards,
Piet
Mensaje modificado, 08,septiembre 2018 - 19:44
Miembro registrado
498 mensajes
Popularité : +8 (8 votes)
Publicado el 10,septiembre 2018 - 15:24
Hi

Yes it's a multiline text but! I do some HTML on my text just to have some visual effects I guess maybe that could be the problem I still don't know.
I will put the alert and see what's happening thanks!

I will let you know if I get it to work or something!

--
Best Regards
ARV
Miembro registrado
498 mensajes
Popularité : +8 (8 votes)
Publicado el 10,septiembre 2018 - 15:56
Hi

I test it and for some reason it always send me 0 for the scrollheight I put it on line 2 and 3.

Thanks for the reply by the way!

--
Best Regards
ARV
Miembro registrado
498 mensajes
Popularité : +8 (8 votes)
Publicado el 10,septiembre 2018 - 18:18
Hi Piet

I remember something! maybe this could happend because the way I put info on my edit it's from browser events (AJAX mode) that's maybe why it send me 0 the scrollbarheight

what do you think?

--
Best Regards
ARV
Miembro registrado
17 mensajes
Popularité : +1 (1 vote)
Publicado el 11,septiembre 2018 - 10:45
Hi ARV,

If it's a HTML edit control then it won't work, because WB uses a set of controls instead of a simple input.
So if you're creating some kind of chat, it's best to have a simple input for the user and display the chat history in a different control (rta)
To scroll an rta you need to set the style to Overflow: with scrollbar.
Also you don't use the alias but the alias with "dz" in front of it (e.g. dzA2).

Kind regards,
Piet
Miembro registrado
498 mensajes
Popularité : +8 (8 votes)
Publicado el 11,septiembre 2018 - 15:28
Hi Piet

Thanks fo the help!

I see it won't work with HTML that's too bad...

Ok I will check this rta you said ( but it's sound more like rtf haha!) but I will search if I found something
Yes you get it I want to create some kind of chat you get me (I forgot to changed the name of my edit hehe)

Thanks for the reply and the ideas I will let you know if something happends ok? thanks!

--
Best Regards
ARV