PxPlus User Forum
Main Board => Discussions => Webster Plus => Topic started by: Zereliq on August 23, 2022, 10:21:22 AM
-
Fairly simple question:
Is it possible to make some rows locked and others open see images for example :D
And if it is possible, would this be possible with an [if] block based on the row number
-
There is actually a pretty easy way to do this.
On the memory file used to maintain the grid add a field and call it something like lockrow$.
Now on the grid definition for the cells you want locked add the option (lockrow$) so the column definition looks something like this:
[col Source=clientid$ ttl="Client" width=10 (lockrow$)][/col]
Now on the row you want locked simply set the variable lockrow$ to "locked".
Basically when Webster processes the column it will evaluate the expression (lockrow$) which will be "locked". You can have any options represented as fields in the grid memory file or event have things such as class=(fieldname$)
-
After a lot of playing around and also letting some college's with a lot more PxPlus experience try to get it to work we still have not been able to lock rows/fields based on a variable. What it seems to do is eigther lock all or unlock none.
We were able to determine that if you make a button that switches the state of the variable it changes all fields/rows that have the variable included. so sadly still have not found the solution to this question, any suggestions?
-
Sorry, my bad, I should have noted and mentioned that in the grid the [col] is evaluated once during the grid definition, but the values between [col] and [/col] are done on each row so my example was incorrect.
So here is HTML that shows how to accomplish what you are looking for:
[ttl]Grid Demo[/ttl]
[form program=grid_sep7]
[subttl]Grid below shows locking columns[/subttl]
[grid mygrid size=50% program=grid_sep7]
[col ttl="Col1" width=10][input col1$ (lck1$)][/col]
[col width=15 ttl$="Col2"][input col2$ class="text_blue,font_bold" (lck2$)][/col]
[col ttl="Col3" width=15 class="align_center"][input col3$ (lck3$)][/col]
[/grid][/form]
You will notice that the (lckx$) option is inside the [col] short code tags thus will be evaluated on each row.
Here is the associated program that loads the grid and the lock settings.
load_grid:
enter gridhdl
!
open (hfn,iol=grid_iol)"*memory*"
gridhdl=lfo
!
for rowno=1 to 15
col1$="Col1/Row"+str(rowno)
col2$="Col2/Row"+str(rowno)
col3$="Col3/Row"+str(rowno)
!
if mod(rowno,2)=0 \
then lck1$="locked" \
else lck1$=""
if mod(rowno,3)=0 \
then lck2$="locked" \
else lck2$=""
if mod(rowno,4)=0 \
then lck3$="locked" \
else lck3$=""
!
write (gridhdl)
next rowno
!
end
!
grid_iol: \
iolist col1$,lck1$,col2$,lck2$,col3$,lck3$
Now because of the way a grid works, when you run this the locked cells will not show as grey background. This is because locked cells in a grid cascade the cell background color. If you want them to show as a grey background, you can get around this by adding a class of something like "dynalock" to the [grid] definition then in your system setup add the following custom CSS line:
div.dynalock input[readonly] { background-color: var(--clrbck-locked) !important; }
-
Hey Mike,
This seems to work nicely thanks a lot!
also added some extra css to make other items appear locked too:
div.dynalock ._td:has(input[readonly]), div.dynalock ._td:has(input[data-lock="Y"]) {
background-color: var(--clrbck-locked) !important;
}
-
Glad it worked for you.
One thing, the :has(...) CSS selector is not supported on all browsers -- specifically its not supported by Firefox without user enabling it.
https://caniuse.com/css-has
Long-term it will likely work, but you may find some issues depending on the browser being used.
-
seeing how recently Safari has implemented the :has() function i don't think it will take long for Firefox to do the same,
but since we're using the project mostly internally i dont think we'll run into that obstacle nevertheless i will definitly keep it in mind when using it in future webster+ projects ;)
-
Technically FireFox has implemented the has () function however you have to this is done based on the layout.css.has-selector.enabled flag which the user has to enable.
-
so i think i already know the awnser to this question but its worth asking;
is it possible to change/update a variable like the "locked" after the write?
so for example im trying to change background-colors of cells based on changed made in other cells
or changing locks also based on changes made in other cells.
project_bg$="red"
[class=(project_bg$)]
-
Sure -- Set a variable to either text_red (for red text) or fill_red (for red background) then add class=(color$) or whatever your variable is and set the variable to "text_red" or "fill_red".
You could also do something like: class=("fill_"+backClr$)