Page 1 of 1
Make datagrid rows partially uneditable
Posted: Fri May 16, 2014 11:00 am
by Tate83
Hi all,
Is there something like dgColumnIsEditable [COLUMN] for rows?
I would like to have certain rows (with value X in colun 1) displayed but not editable, while other rows (without X in column 1) are.
Thanks,
Pascal
Re: Make datagrid rows partially uneditable
Posted: Fri May 16, 2014 1:19 pm
by Klaus
Hi Pascal,
Tate83 wrote:Is there something like dgColumnIsEditable [COLUMN] for rows?
yes, it is
Load the DataGrid PDF and look for that property "dgColumnIsEditable":
http://lessons.runrev.com/m/datagrid
Sorry, never worked with that prop.
Best
Klaus
Re: Make datagrid rows partially uneditable
Posted: Fri May 16, 2014 1:30 pm
by Tate83
Hi Klaus,
Thanks, I have seen that document before. I already protected the columns, but I also need a partial protection on the rows. Basically this:
Code: Select all
R/C Colum A Column B
Row 1 1 editable
Row 2 1 editable
Row 3 0 protected
Row 4 1 editable
Column A is protected (implemented)
Column C is bascially writable, BUT only for rows where Column A = 1.
Re: Make datagrid rows partially uneditable
Posted: Fri May 16, 2014 5:32 pm
by dunbarx
Hi.
I looked around the DG docs, and do not see such a property. I wonder if there is such a thing. Fooling around with a kluge in the meantime...
Craig Newman
Re: Make datagrid rows partially uneditable
Posted: Fri May 16, 2014 5:49 pm
by dunbarx
Someone please rescue me from myself.
Ugly as sin, and I suspect the right way to do it is in the mind of somebody smarter. But this works, though it does not really block the row from being accessed, it just sort of thumbs its nose at anyone who tries to edit within that row. With a DG of a few lines, put this in the group script:
Code: Select all
on rawKeyDown
if the selectedField <> "" and there is a field "datagridFieldEditor" and the dgHilitedLines of grp 1 = 2 then
set the lockText of fld "datagridFieldEditor" to "true"
else
pass rawKeyDown
end if
end rawKeyDown
It will block text entry into row 2.
Ugh, though.
Craig
EDIT:
Tried setting the focusable to "false" and the visible to "false". All these work as well (or as poorly). There is likely a better kluge that does not rely on rawKeyDown, that is, after the editing field is created. In this way the field would never appear. Working...
EDIT 2: Don't want to use an idle handler to detect if the DGhilitedLines is 2, say. This could do it with any of the kluge methods above. Hate idle handlers, though.
Craig