Make datagrid rows partially uneditable

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
Tate83
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 30
Joined: Fri Mar 01, 2013 1:11 am

Make datagrid rows partially uneditable

Post by Tate83 » Fri May 16, 2014 11:00 am

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

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Make datagrid rows partially uneditable

Post by Klaus » Fri May 16, 2014 1:19 pm

Hi Pascal,
Tate83 wrote:Is there something like dgColumnIsEditable [COLUMN] for rows?
yes, it is :D

Load the DataGrid PDF and look for that property "dgColumnIsEditable":
http://lessons.runrev.com/m/datagrid

Sorry, never worked with that prop.


Best

Klaus

Tate83
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 30
Joined: Fri Mar 01, 2013 1:11 am

Re: Make datagrid rows partially uneditable

Post by Tate83 » Fri May 16, 2014 1:30 pm

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.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10305
Joined: Wed May 06, 2009 2:28 pm

Re: Make datagrid rows partially uneditable

Post by dunbarx » Fri May 16, 2014 5:32 pm

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

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10305
Joined: Wed May 06, 2009 2:28 pm

Re: Make datagrid rows partially uneditable

Post by dunbarx » Fri May 16, 2014 5:49 pm

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

Post Reply