Selecting cells in Table Fields

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: Klaus, FourthWorld, heatherlaine, robinmiller, kevinmiller

Post Reply
user#606
Posts: 217
Joined: Sun Jan 27, 2008 12:25 pm
Location: Alderney, Channel Islands
Contact:

Selecting cells in Table Fields

Post by user#606 » Mon Jan 28, 2008 11:34 am

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.

Chris_Wood
Posts: 11
Joined: Sun Jan 06, 2008 1:22 am

Selecting Cells in Table Fields

Post by Chris_Wood » Tue Jan 29, 2008 4:49 am

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

user#606
Posts: 217
Joined: Sun Jan 27, 2008 12:25 pm
Location: Alderney, Channel Islands
Contact:

Selecting Table Field problem

Post by user#606 » Tue Jan 29, 2008 10:27 am

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

gagsoft
Posts: 167
Joined: Sat Jun 29, 2013 7:56 pm

Re: Selecting cells in Table Fields

Post by gagsoft » Tue Sep 17, 2019 11:33 am

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
on 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
Would appreciate any pointers here as am still testing the waters here

Klaus
Posts: 11416
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Selecting cells in Table Fields

Post by Klaus » Tue Sep 17, 2019 11:52 am

This thread is from 2008 AND it is about the TABLE field, not datagrid, so you better create a new thread for your problem! 8)

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 6336
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Selecting cells in Table Fields

Post by dunbarx » Tue Sep 17, 2019 2:34 pm

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:

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

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”