Selecting cells in Table Fields
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Selecting cells in Table Fields
I have a simple problem with Table Fields. From what I have read, most people do!
The requirement is for the user to click on a line, in any field of the table so the cells of the line in the table can be read by the script.
There may or may not be text in the cell the user chooses, but there will be in nearby cells in that line.
The whole table field is called Cylinders
The text will be locked and disabled so the user cannot change the content.
What code would you write to make this work please?
I have tried various functions etc, but there must be something wrong with the syntax I use. Even the examples do not compile.
The requirement is for the user to click on a line, in any field of the table so the cells of the line in the table can be read by the script.
There may or may not be text in the cell the user chooses, but there will be in nearby cells in that line.
The whole table field is called Cylinders
The text will be locked and disabled so the user cannot change the content.
What code would you write to make this work please?
I have tried various functions etc, but there must be something wrong with the syntax I use. Even the examples do not compile.
-
- Posts: 11
- Joined: Sun Jan 06, 2008 1:22 am
Selecting Cells in Table Fields
Will this work for you?
on mouseUp
put the hilitedline of field "testField" into selectedLineInt --Get the selected row number
if selectedLineInt is "" then --Exit if no row is selected
answer "Please select a row"
exit mouseUp
end if
put line selectedLineInt of field "testField" into itemsInFieldLine --Put all row items into a variable for processing
answer itemsInFieldLine
end mouseUp
Regards
Chris
on mouseUp
put the hilitedline of field "testField" into selectedLineInt --Get the selected row number
if selectedLineInt is "" then --Exit if no row is selected
answer "Please select a row"
exit mouseUp
end if
put line selectedLineInt of field "testField" into itemsInFieldLine --Put all row items into a variable for processing
answer itemsInFieldLine
end mouseUp
Regards
Chris
Selecting Table Field problem
Thank you Chris,
I tried and played about with your code, but am not getting the desired result.
I changed the name testfield to cylinders and that moved things on.
Then I removed the test, because it did not contribute.
The answer just showed empty, whatever was in the field.
If you would prefer, I can send you the offending table for you to see first hand?
Thanks, Alan
Email ajperksx@tiscali.co.uk
I tried and played about with your code, but am not getting the desired result.
I changed the name testfield to cylinders and that moved things on.
Then I removed the test, because it did not contribute.
The answer just showed empty, whatever was in the field.
If you would prefer, I can send you the offending table for you to see first hand?
Thanks, Alan
Email ajperksx@tiscali.co.uk
Re: Selecting cells in Table Fields
Hi guys
I get "group "MyGrid": execution error at line n/a (Object: object does not have this property)" from the datagrid.
The goal is to edit a record.
Here is the code
I get "group "MyGrid": execution error at line n/a (Object: object does not have this property)" from the datagrid.
The goal is to edit a record.
Here is the code
Would appreciate any pointers here as am still testing the waters hereon selectionChanged
put the hilitedline of me into tLine
// put the dgline of me into tLine
Answer tLine
put item 1 of line tLine of me into field "id"
put item 2 of line tLine of me into field "Client"
put item 3 of line tLine of me into field "Contact"
put item 4 of line tLine of me into fld "Phone"
put item 5 of line tLine of me into fld "Issue"
put item 6 of line tLine of me into fld "Issuedate"
put item 7 of line tLine of me into fld "Remedy"
put item 8 of line tLine of me into fld "RemedyDate"
end selectionChanged
Re: Selecting cells in Table Fields
This thread is from 2008 AND it is about the TABLE field, not datagrid, so you better create a new thread for your problem!
-
- VIP Livecode Opensource Backer
- Posts: 9657
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Selecting cells in Table Fields
On the subject of table fields, you really have to read this thread:
viewtopic.php?f=7&t=31452&p=170731&hili ... ly#p170731
The most important entry in it (ahem) is this one:
....Well, you just cannot test too much.
I now find that after programmatically putting empty into a table field the problem comes up anyway. This for both a brand new field and one that has been populated and emptied.
And I like table fields. Cannot imagine how this slipped by. I have used them a lot for many years.
If one populates a certain number of lines and "cells", it seems that "region" becomes stable. BUT ONLY THAT REGION. In other words, one cannot just put "" into the whole field, one must put "" into every cell that might ever be in play. So a variant of my earlier, now useless suggestion, is:
It now seems to be stable with the extent of the above handler, a 5x5 area at the upper left of the field. Outside that extent, the problem appears again. The cells seem to need massaging.
EDIT:
And if anyone was wondering, one cannot simply put "" into the farthest reaches of the table field. Each and every "cell" has explicitly to be set. So the idea of running a plug-in might use 1,000,000 as the indexes in the above handler, and then the issue will likely not come up
Craig
viewtopic.php?f=7&t=31452&p=170731&hili ... ly#p170731
The most important entry in it (ahem) is this one:
....Well, you just cannot test too much.
I now find that after programmatically putting empty into a table field the problem comes up anyway. This for both a brand new field and one that has been populated and emptied.
And I like table fields. Cannot imagine how this slipped by. I have used them a lot for many years.
If one populates a certain number of lines and "cells", it seems that "region" becomes stable. BUT ONLY THAT REGION. In other words, one cannot just put "" into the whole field, one must put "" into every cell that might ever be in play. So a variant of my earlier, now useless suggestion, is:
Code: Select all
on mouseup
set the itemDel to tab
put empty into fld 1
repeat with x = 1 to 5
repeat with u = 1 to 5
put "" into item u of line x of fld 1
end repeat
end repeat
end mouseup
EDIT:
And if anyone was wondering, one cannot simply put "" into the farthest reaches of the table field. Each and every "cell" has explicitly to be set. So the idea of running a plug-in might use 1,000,000 as the indexes in the above handler, and then the issue will likely not come up
Craig