Main Board > Webster Plus

Row based Column locking / disabling

(1/2) > >>

Zereliq:
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

Mike King:
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$)

Zereliq:
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?

Mike King:
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:


--- Code: ---[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]
--- End code ---

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.


--- Code: --- 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$

--- End code ---

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; }





Zereliq:
Hey Mike,

This seems to work nicely thanks a lot!

also added some extra css to make other items appear locked too:

--- Code: ---div.dynalock ._td:has(input[readonly]), div.dynalock ._td:has(input[data-lock="Y"]) {
 background-color: var(--clrbck-locked) !important;
}
--- End code ---

Navigation

[0] Message Index

[#] Next page

Go to full version