Delete Script assigned to a column or whatever

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

planix
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 47
Joined: Tue Mar 10, 2009 12:47 pm

Can you prevent editing of datagrid column fields

Post by planix » Fri Sep 14, 2012 2:13 am

Hi All,

This is for my information only at this point.

I am developing a database and using datagrid to display table data. Currently I edit the rows in the datagrid by using a separate card with fields related to the database. I then write the data from that card to the database and update the datagrid.

It's clear that a more sophisticated approach would be to have the user change the data(edit or add new row) in the datagrid fields and then write that row to the database.

I haven't come to grips with how to write the updated or new rows from the datagrid to the database but I am pretty sure that is a straightforward issue, from what I have read in the datagrid manual (http://lessons.runrev.com/s/lessons/m/d ... ata-source). Though if anyone has some example code of how to do that, since the author left that as an exercise for the reader, my lazy self would be most grateful :wink:

However, my main question is whether it is possible to restrict which column fields can be edited? I have a datagrid which contains data from two tables in the database. I want the user to be able to edit a limited set of columns as some of the columns have data from the linked table and I don't want them to change that.

cheers
****************************************
PLANIX
"Knowing anything is better than knowing nothing. But knowing that nothing ain't anything, why that's just plain nirvana."

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

Re: Can you prevent editing of datagrid column fields

Post by dunbarx » Fri Sep 14, 2012 6:30 am

Hi.

Check out the "dgColumnIsEditable[]" property.

set the dgColumnIsEditable[3] to "false".

Locks out column 3.

Craig Newman

planix
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 47
Joined: Tue Mar 10, 2009 12:47 pm

Re: Can you prevent editing of datagrid column fields

Post by planix » Fri Sep 14, 2012 6:44 am

Thanks,

I'll have a look at that
****************************************
PLANIX
"Knowing anything is better than knowing nothing. But knowing that nothing ain't anything, why that's just plain nirvana."

aetaylorBUSBnWt
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 118
Joined: Thu Sep 20, 2012 5:11 pm

Re: Can you prevent editing of datagrid column fields

Post by aetaylorBUSBnWt » Sun Oct 16, 2022 5:08 pm

OK, there is a dgColumnIsEditable[] property.

Nowhere near enough information for a beginner, especially for DataGrid which has groups within groups within groups.....


I have been going through the DataGrid lessons and have not found the one that gets you to the point where I can change the actual properties of a particular column - specifically being able to turn off editing on a particular column.
Looking at the UI, it would seem that making sure that the "Lock Text" checkbox is clicked with the checkmark in it would do that.
But it does NOT.

So my steps:
Created a DataGrid that is a Table in a Card in a substack
Added a Column
Added a Column Behavior for that Column via the + button in the UI.
Went to back to Data Grid tab for that and clicked on Row Template...
I get the Editing Template window up and verify that Select Grouped is off in the Toolbar
Then I click on the name of the Column I see in the window and the Property Inspector says "group Row Template"
So then I click on Edit Group in the Toolbar
It switches to Stop Editing in the Toolbar
The property inspector window title switches to stack Data Grid Templates (with a long number)
Then I click on the column name in the Editing Template window - which I just noticed has a different title -- "Editing template (background "Row Template")
Then I click on the column name of the column I want to edit and the property inspector now says "group clnID" (clnID is the of the column)

Image

So now I click "Edit Group" in the Toolbar, yet again!!!
and the property inspector window becomes USELESS!!
It says "stack Data Grid Template" and the "Editing template" window is now titled "background "clnID")
So I click on the column name in the Editing Template window again.
I then get the Property Inspector to be titled: field _ColumnData_ and if I click on the contents it says "clnID" which is the column I want to change the attributes of.

Under the Basic tab, "Lock Text" is checkmarked.
So it would seem that after all this, I have the properties of the COLUMN TITLE, sort of maybe.

Even though "Lock Text" is checkmarked, double clicking on a table cell in that column allows me to edit that column in any row.
If I set the "Disabled" property via this Property Inspector, it shows the entire column in Grey.
So clearly at this level, more than just the title row is being affected, but why?

How do I get down to the level of the rows themselves, NOT the title row?
That is where I want to set the Lock Text so that the column can't be edited. I do NOT want the column to be Grey.
I looked at the "Table" tab at this level. I don't see anything there that affects what I want (no idea what is going on there - don't care right now).

Image

Oh, and by the way, while making this column Gray by checkmarking the Disabled box, that does not STOP editing. It just stops entering editing if you double click on that cell. If you double click on an adjacent cell and enter editing mode on that adjacent cell, typing shift tab will back you up to the "Disabled" cell and allow you to edit it. Same with typing return often enough to step through the columns of the row to get to the Disabled cell - you can still edit it.

So how to actually change the properties of the "data" rows?
Specifically, stopping editing?

Thanks for any help.

aetaylorBUSBnWt
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 118
Joined: Thu Sep 20, 2012 5:11 pm

Delete Script assigned to a column or whatever

Post by aetaylorBUSBnWt » Sun Oct 16, 2022 5:39 pm

Hello,

I am trying to use Data Grid - not going well at all.

I wanted to stop editing of a column - nothing I find allows for that.
How do I do that?
(and don't just tell me to set the dgColumnIsEditable property - I have no idea where such code would be put)

Along the way, I deleted the contents of the Script that got associated with the column, making the stupid assumption that meant that Livecode would stop accessing it.

Now the column is useless - no data displayed.

How to do I get the column back to where it was - no column behavior?

Thanks

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10094
Joined: Fri Feb 19, 2010 10:17 am

Re: Delete Script assigned to a column or whatever

Post by richmond62 » Sun Oct 16, 2022 5:46 pm

Possibly ?
-
SShot 2022-10-16 at 19.44.22.png
SShot 2022-10-16 at 19.44.22.png (38.59 KiB) Viewed 4904 times
-
Mind you, I have NEVER used a DataGrid (until just now): so I am probably wrong.

aetaylorBUSBnWt
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 118
Joined: Thu Sep 20, 2012 5:11 pm

Re: Delete Script assigned to a column or whatever

Post by aetaylorBUSBnWt » Sun Oct 16, 2022 5:54 pm

tried that - it just grays the column, it can still be edited.

in addition i dont want the column gray, i want Lock text, like in a label to do its job.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10094
Joined: Fri Feb 19, 2010 10:17 am

Re: Delete Script assigned to a column or whatever

Post by richmond62 » Sun Oct 16, 2022 5:59 pm

OK, OK, that was rubbish.

BUT I do have a problem understanding the Dcitionary:
-
SShot 2022-10-16 at 19.56.44.png
-
as I have not idea how, using that syntax, you'd set things to true or false.

What I would have thought was self-evident syntax produces no joy:
-
SShot 2022-10-16 at 19.57.11.png
-
OK: this is ODD, but seems to make the ability to edit the column false:
-
SShot 2022-10-16 at 19.59.48.png
-
Mind you, how you make the editable true again is . . . ?

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10045
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Delete Script assigned to a column or whatever

Post by FourthWorld » Sun Oct 16, 2022 6:04 pm

Duplicate thread merged, so it's now clearer where replies should go, and so future readers can find related posts in one place.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

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

Re: Delete Script assigned to a column or whatever

Post by Klaus » Sun Oct 16, 2022 6:07 pm

Works here:

Code: Select all

...
set the dgColumnIsEditable["Col 2"] of group "dg1" to FALSE
...
And no editing after doubleclicking that column!

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10094
Joined: Fri Feb 19, 2010 10:17 am

Re: Delete Script assigned to a column or whatever

Post by richmond62 » Sun Oct 16, 2022 6:26 pm

Works here:
Well, it would, wouldn't it . . . :)

Actually, I thought it had not worked as I received no VISUAL CUE.

aetaylorBUSBnWt
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 118
Joined: Thu Sep 20, 2012 5:11 pm

Re: Delete Script assigned to a column or whatever

Post by aetaylorBUSBnWt » Sun Oct 16, 2022 7:51 pm

Klaus wrote:
Sun Oct 16, 2022 6:07 pm
Works here:

Code: Select all

...
set the dgColumnIsEditable["Col 2"] of group "dg1" to FALSE
...
And no editing after doubleclicking that column!
OK, fine, BUT where do you put this code?

and 2nd:

If one deleted all the code in a script assigned to a Column behavior in a DataGrid, how do you get back to the default code that was filling in the column when the DataGrid was created.

Originally I did not have any column behaviors, only code at the Card level that filled in the entire DataGrid table.
I want to get back to no column behaviors, yet I can't find a means to disconnect the empty script from that column.

aetaylorBUSBnWt
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 118
Joined: Thu Sep 20, 2012 5:11 pm

Re: Delete Script assigned to a column or whatever

Post by aetaylorBUSBnWt » Sun Oct 16, 2022 8:59 pm

aetaylorBUSBnWt wrote:
Sun Oct 16, 2022 7:51 pm

and 2nd:

If one deleted all the code in a script assigned to a Column behavior in a DataGrid, how do you get back to the default code that was filling in the column when the DataGrid was created.

Originally I did not have any column behaviors, only code at the Card level that filled in the entire DataGrid table.
I want to get back to no column behaviors, yet I can't find a means to disconnect the empty script from that column.

After deleting the screwed up columns, saving the world, and quitting Livecode completely, I re-opened and went back to that DataGrid and tried the add the columns back in again. The offending behaviors and modified properties show up again anyway!

So tried deleting it all again, saving, quitting, restarting - still there.

So next via the Project Browser, I started digging around in the Data Grid Templates.
I have several Data Grids on different cards.
Well after digging around i eventually found a card that still had the columns that I had deleted multiple times still present.
I also found that the scripts that had been associated with the deleted columns were also present in those Templates.

So annoyingly, apparently deleting a column from a Data Grid does not actually delete the column or stuff associated with it.
You have to go dig around in the back to get stuff deleted.
Given the above, don't even bother deleting via the UI, waste of time - you have to go get it out of the templates.

Seems like a bug to me.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10094
Joined: Fri Feb 19, 2010 10:17 am

Re: Delete Script assigned to a column or whatever

Post by richmond62 » Sun Oct 16, 2022 9:10 pm

I have always been entirely happy with Table Fields, and the first time I looked at datagrids was:

1. Datagrid #1: 10 years ago, for about 30 minutes.

2. Datagrid #2: just now, much the same.

They are, supposedly, much more clever things than table fields, and they may be.

My main problem is that I am NOT much cleverer than a table field. :?

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10094
Joined: Fri Feb 19, 2010 10:17 am

Re: Delete Script assigned to a column or whatever

Post by richmond62 » Sun Oct 16, 2022 9:14 pm

where do you put this code?
How about in a button?

Post Reply