Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
General
GeneralPortable MacsHardwareNetworking
Applications
Mac ApplicationsEudoraFirefox / MozillaInternet ExplorerOutlook ExpressMS OfficeEntourageExcelPowerPointWordVirtual PCMedia PlayerOther MS Products
Programming
Mac ProgrammingCodeWarriorPerl
Country Specific
Australian Mac GroupUK Mac Group

Mac Forum / Programming / Mac Programming / April 2006



Tip: Looking for answers? Try searching our database.

Updating data source from table view

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Spidey - 24 Apr 2006 19:15 GMT
I am using table view to display the contents of my data source.

The table view has a check box.  When the user makes changes, my
underlying data source does not get the change.

What do i need to do to make the underlying data source update from
change made in the table view?

BTW this is written in XCode using Applescript.

Thanks.
matt neuburg - 24 Apr 2006 19:53 GMT
> I am using table view to display the contents of my data source.
>
[quoted text clipped - 5 lines]
>
> BTW this is written in XCode using Applescript.

That is not "BTW" - it is crucial. If you're using AppleScript Studio,
you need to say so up front.

You also need to say more about how you've set this up, because if is
not working for you right out of the box, you've done something very
wrong. I will give an example. In IB, I put a table view in the window
and attached the "checkbox" cell to the first colum. I hooked up the
table's "awake from nib" to my script, and in the script, I put this
code:

on awake from nib theObject
 set t to (get table view 1 of scroll view 1 of window 1)
 set content of t to {{true, "ha"}}
end awake from nib

Sure enough, the checkbox appears checked for the one row when the app
runs. Now I add a button to the window, with this clicked handler:

on clicked theObject
 log (get contents of every data cell of every data row of data source
of table view 1 of scroll view 1 of window 1)
end clicked

Sure enough, if I check or uncheck the checkbox and then click the
button, the logging shows "true" or "false", corresponding to the state
of the checkbox. m.

Signature

matt neuburg, phd = matt@tidbits.com, http://www.tidbits.com/matt/
Tiger - http://www.takecontrolbooks.com/tiger-customizing.html
AppleScript - http://www.amazon.com/gp/product/0596102119
Read TidBITS! It's free and smart. http://www.tidbits.com

Spidey - 24 Apr 2006 22:26 GMT
I am new to AppleScript so hopefully when i explain this so it makes
sense.

I am creating a new data source in applescript, adding columns to it,
and then adding data to it.

I also have a Tabe View that was created in XCode.

My applescript code does:
set data source of table view 1 of scroll view 1 of window 1 to
datasource

This works fine as the table view gets populated.

Now if the program is run, and the user makes a change in the table
view grid, the change is not in the datasource.

I test this buy having a button that loops through all the rows and
displays the information.

Is there a command something like...
set datasource to values in table view 1 of scroll view 1 of window 1

hope this helps to clarify the problem.
matt neuburg - 25 Apr 2006 00:34 GMT
> I am new to AppleScript so hopefully when i explain this so it makes
> sense.
[quoted text clipped - 9 lines]
>
> This works fine as the table view gets populated.

Okay, but you no longer have to do that. Did you look at the code in my
previous reply? You can just set content of the table view directly.
There is no need to talk explicitly about a data source any more. But
you can if you want to.

So, from my previous example, I change the awake from nib code to this:

on awake from nib theObject
       set t to (get table view 1 of scroll view 1 of window 1)
       set d to (make new data source at end of data sources)
       tell d
               make new data column at end of data columns with
properties {name:"colone"}
               make new data column at end of data columns with
properties {name:"coltwo"}
               append it with {{colone:false, coltwo:"ha"}}
       end tell
       set data source of t to d
end awake from nib

And again, I check the data source's contents like this:

on clicked theObject
       log (get contents of every data cell of every data row of data
source of table view 1 of scroll view 1 of window 1)
end clicked

It responds correctly when the user edits the data in the table.

> Now if the program is run, and the user makes a change in the table
> view grid, the change is not in the datasource.
[quoted text clipped - 4 lines]
> Is there a command something like...
> set datasource to values in table view 1 of scroll view 1 of window 1

No, because there is no need. The whole point of the data source is that
it is where the values are already.

> hope this helps to clarify the problem

No, it doesn't. You don't show any code. I do. My code works. Either
make yours look like mine or show yours so that it can be corrected. m.

Signature

matt neuburg, phd = matt@tidbits.com, http://www.tidbits.com/matt/
Tiger - http://www.takecontrolbooks.com/tiger-customizing.html
AppleScript - http://www.amazon.com/gp/product/0596102119
Read TidBITS! It's free and smart. http://www.tidbits.com

Spidey - 25 Apr 2006 14:13 GMT
Ok, thanks amazingly you seem to have pointed me in the right
direction.

I was using 0/1 in my datasource, but the check box was changing it to
true/false.  Becuase if my inexperience with Applescript i was looking
for a command that would update the datasource from the grid.  I
realize now that it was not needed.

Thanks.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.