Need help getting current row of table

Hello, I have a table with a array. Im trying to get the selected row contents when I click a button not in the table.

Im not sure what I need to be addressing. The tableview or the array. Can somebody give me some help here.

My Properties are


property thelookupArrayController : missing value -- The array controller
property theLookupTable : missing value -- The tableView

One way is to use the array controller’s selectedObjects method. Since it returns an array, you’ll want to get the object at index 0 or the last object if you want a single row’s data.

log thelookupArrayController’s selectedObjects()'s lastObject()

Ric

Thanks Ric. Just what I needed :slight_smile:

Hey Rick, your solution works but. Can you give me some guidence on how to work with the results?

My result
Im looking to get the items in quotes into a list (peki@me.com,Pete k,dave harding etc…)

{
        CSREmailcolumn = "peki@me.com";
        CSRNamecolumn = "Peter k";
        CustContactcolumn = "Dave Harding";
        CustEmailcolumn = "dharding@mejer.com";
        CustIDcolumn = 085;
        CustNamecolumn = "Mejer Fine Foods";
        Descriptioncolumn = "POP stand up display + Tab on pad";
        DueDatecolumn = "Tuesday, November 15, 2011 11:34:09 AM";
        OrderIDcolumn = 00038;
        bleedcolumn = ".125";
        distHcolumn = 100;
        distVcolumn = 100;
        fileNamecolumn = "Mejer fine foods";
        gapHcolumn = ".125";
        gapVcolumn = ".125";
        jdfcolumn = "4pg_2x1";
        jobNamecolumn = "Mejer fine foods";
        mfgcolumn = "missing value";
        pressTypecolumn = "Indigo 6000";
        proofTypecolumn = WebCenter;
        rotationcolumn = 0;
        stepHcolumn = 1;
        stepVcolumn = 1;
        subOrderIDcolumn = 001;
        subVcolumn = 1000;
        subWcolumn = 2000;
        trapDistancecolumn = ".003";
        trapRequiredcolumn = No;
        workflowcolumn = Commercial;
    }

NSDictionary has a method, allValues(), that creates a new array from the dictionary, but the order of the items will be undefined. Will that work for you?

Ric

well I plan on restoring these values to different fields in the app. So I will need to know either by record name or item count what item of the record I am working with so I know where it needs to go.

I’m not sure that I understand what you want then. The result you got is a dictionary with all the info you need – you can use valueForKey to get a value for a particular key, and then put that in wherever field you want.

Ric

Ah, I see (I think)

This is giving me the correct info I need. Is there a better way to do this?

on getCurrentRow_(sender)
		set SelectedRecord to thelookupArrayController's selectedObjects()'s lastObject()
		set theSelectedOrderID to valueForKey_("OrderIDcolumn") of SelectedRecord
		log theSelectedOrderID
	end getCurrentRow_

Thanks for the help Ric

No, i think that’s the way to go.

Ric

After Edit: There is another way to do this with no code at all, and that’s with bindings, if I’m understanding what you want to do. In your table you would have a column bound to the array controller’s arrangedObjects.CSREmailcolumn for instance. If you wanted that data to appear in a text field, you could bind that text field’s value to array controller’s selection.CSREmailcolumn – that would populate that text field with whatever is the value of the CSREmailcolumn column of the selected row.