Where can I bind column cell view controls? - objective-c

I've been Googling for 3 hours, I can't find where to bind these things for Core Data in this textbook I'm reading. I just want to know where to find out where to bind it. I assume it's in the binding inspector after you highlight a column but under value it doesn't show anything like "Col 0 Image View" and for the first column I can't see a section that includes two places to set a binding which needs for an Image View and a Text Field. Below is an excerpt (as well as I can copy it) from the textbook Cocoa Programming for Mac OS X 4th Edition chapter 11, page 185.
"Now bind the value of each column's cell view control(s), as shown in the following table."
One of the entries in the table is:
Binding valueof Col 0 Image View
Bind to Table Cell View
Controller Key Empty
Key Path objectValue.photo

So after a day's work of searching and random clicking I found this rather elusive, yet out-in-the open binding. I hope this helps anyone else who might be frustrated.
This is where to find it, you want to click the one that shows what I have circled. Open the bindings inspector and then it'll pop up with objectValue already populated in your key path.
The first column has two since it has an image view and text view. Make sure to select the appropriate one for whichever one you want bound.

Related

BIRT result set values in specific cells

My query returns location_cd(string) and item_count(int). I only need certain rows from the result however and I need them to display in specific places in my layout so I don't think the table solution is going to work. Can I determine where I place the value for a particular row of the result set?
I am using a grid to display values for a number of fields. I cannot seem to be able to get the values from the results to show. The grid is bound to the result set. I even tried binding the cells to the result set but that didn't work either.
I checked in the query editor and there is a result set shown in the Preview so I know the query works. The complete and correct result set shows if I put a table on the page.
I tried inserting a Dynamic Text or Data object in a cell and used the expression:
dataSetRow["location_cd"]=="3SD"?dataSetRow["item_count"]:""
This returns a blank and does not seem to evaluate. I tested it with :
dataSetRow["location_cd"]=="3SD"?dataSetRow["item_count"]:"BLANK"
and got 'BLANK' to appear in that cell.
dataSetRow["location_cd"] and dataSetRow["item_count"] will display the location_cd and item_count from the first row of the result set. row.outer[] did the same thing. Obviously I am just hacking at this report at this point.
A co-worker suggested that she uses a JAVA if-statement in places like this but I could not get that to work either.
Any ideas or suggestions that will get me on the right road??
Thanks
An elegant option would be to use a HashMap storing the result of the dataset.
Declare a report variable named "values", with a new hashmap as default value (see image below)
Fill values in the onFetch script of the dataset: vars["values"].put(row["location_cd"],row["item_count"]);
Insert new data elements at any place of the report with expressions such: vars["values"].get("myFavoriteLocationCD");
Though it is important to note the dataset should be triggered by the report before these data elements.
The particular row you want to display you specify in a "Text" field inside your grid. Just drag and drop a "Text" field inside your grid. If you bound the fields you want to display to your grid, the "Text" field inside the grid inherits the bindings of its parent (the grid), so you can access the bindings automatically in the "Text" field.
You could try following steps, maybe that works.
Don't use "Dynamic Text" field, instead use a regular "Text" field
Ensure the fields of your query which you use, are bound to the grid (you sayed you already did)
Open the "Text" field
Change preselected pull-down entry "Auto" into "HTML"
Change preselected pull-down entry "Formatting" into "Dynamic Text"
Wrap your code in <value-of format="HTML"> your code goes here... </value-of>
Note: You should check in the "Expression Builder" of your "Text" field if you are able to access the fields you bound to the grid. If they are not available sth. went wrong with your binding. Avoid binding query records to cells this will drive you crazy.
If you want to display a list, ensure you didn't set a constant height in the row of your grid. Set the height to 100% than the row takes its height dynamically.
What about the idea to optimize your query, that only get the results you want are displayed, than you don’t need to filter them with java script? If you don’t need the filtered results in another place this would be the cleaner solution in my opinion.

Core data relationships: popup button can select a relationship but the name is not displayed

After a lot of time wasted due to a core data relationship fault, now I'm able to bind a popup button cell to an entity relationship.
The only problem now is that when I select and browse all the options the names are displayed, but when I choose the relationship and click on it, the name disappears.
The entities are very simple:
So a person can have 0 or 1 home, a home can have 0 to N people (inverse relationship).
I have an array controller named "people" which is in entity mode, bound with the people objects of managed object context.Same for "homes", which is bound with the homes objects.All the names in the table views are displayed correctly, except for the popup button.This is what I see when it's selected:
And this is what I see when it's not selected:
So like you see the cell is empty.The popup button's bindings are:
1. Content: "homes" arranged objects;
2. Content values: "homes" arranged objects.name;
3. Selected object: "people" selection.home .
So coming to the question: why does not the popup button display the relationship name when it's not selected?
PS: The table view is cell based.
That has been a pain to me, and lastly I solved it so there's the explanation for who will find my same problem: I was mixing view based table views with cell based table views.If you want to bind a cell based table view, do not bind the table view content to the managed object context, but bind it's columns.For the popup button I cancelled all bindings and bound it's column this way:
Content: "homes" arranged objects;
Content values: "homes" arranged objects.name;
Selected object: "people" selection.home .
So this may seem the same, but now is the table column to have these bindings, not the button cell.And now all works fine.
Thanks for your answer! I tried to solve such a problem for a couple of hours and the problem was that I had bound the table content to the controller. Now I just bind the column to the controller and everything works as expected.

How to show button cell (check box) title in table view, using bindings

I am trying a simple application where I have a mutable array of mutable dictionaries, such as -
NSMutableDictionary *sample6 = [[NSMutableDictionary alloc] initWithObjectsAndKeys:#"title6",#"title",[NSNumber numberWithBool:NO],#"state", nil];
In IB I created a table view with NSButtonCell (check box).
I was able to show checkboxes state (checked or unchecked), using following table column bindings:
Value - ArrayController.arrangedObjects.state
In this case it shows an array of checkboxes with title - "Check" as shown in below screen-shot:
Now my aim is to show checkboxes title using bindings, such that it
gets value from same mutable dictionary from which it is getting its
state.
I tried following binding for button cell but it did not work:
title -> ArrayController.selection.title
I also tried this binding for button cell :
title -> ArrayController.arrangedObjects.title
but it didn't work, it appeared like this after using above binding:
Can any one suggest me which controller key to use and if this is not the correct way to show titles then what is the correct way to do so?
Unfortunately you'll need to write a little code if you want to do it this way. When binding table column values to an array, the table column is handling taking the prototype data cell, setting its values, and "stamping" it in place for each row. The button cell's bindings aren't exposed "through" the table column, so a simple binding won't do it for you.
To Answer Your Question
So. Since only the value binding is exposed, the title must be set manually if you really want the checkbox's title to reflect the value (ie, you really want the checkbox to handle both the check state and displaying the title). To do this, you have to mix bindings with < NSTableDelegateProtocol > . Use the -tableView:willDisplayCell:forTableColumn:row: method to set the cell's -title property to that of the proper object in your array controller's -arrangedObjects array each time you're asked. Mixing bindings and data source / delegate methods is actually quite common for more than the most basic applications, so don't worry that you're doing something dirty. Note: you won't be able to support editing the title by doing this since it's a checkbox.
An Alternative Design
Personally, I'd avoid all that and just add a separate table column for the title. Bind the new column's value to the array controller's arrangedObjects.title and turn off the checkbox button cell's title so only the checkbox itself is displayed. That simplifies the whole thing greatly and allows editing the title.

Binding to NSMatrix for BOOL attributes

I have a simple core-data entity that has a Boolean attribute called subscribedToNewsletter. I have designed my UI to represent this field as a radio button group with Yes/No as the text values (and obviously YES/NO as the backing BOOL values).
I have always considered myself to have excellent google-fu, but for the life of me, I am unable to find any clear documentation on:
how to bind the selected value of the NSMatrix (or is it the cell?) back to a YES/NO value
how to bind the textual values (if indeed I do need to; I know there are only ever going to be two values - surely they can be hard-coded in Interface Builder, or not?)
Next up will be how to bind a radio group (with Male/Female text) to a String field called gender that has M and F as possible values - but I digress.
Any pointers would be very much appreciated. Thanks a lot.
Not sure if I got no answers because a) it is such a stupid question, or b) no-one in the world knows how. The latter doesn't strike me as likely, so I can only presume the first :)
Anyway just in case there others as stupid as me, I thought I'd give some feedback on how I managed to achieve it.
In Interface Builder, I created a NSMatrix with two radio button cells with "Yes" and "No" as the text for each respectively. In the Attributes Inspector (command-1), make sure the Tag field is set to 1 for the "Yes" button cell, and set to 0 for the "No" button cell. Then, in the Bindings Inspector (command-4) bind the SelectedTag field for the matrix to the Boolean property on your entity. Easy as pie.
I make no claims that this is the best way... just that it is effective.
I have found one solution for this part-
how to bind the selected value of the
NSMatrix (or is it the cell?) back to
a YES/NO value
Here is the link to the problem which I faced and its solution- NSMatrix simple binding question
Hope this helps !

How to add a checkbox in front of folder tree in finder with Mac?

I want to change a outline view , and add checkbox cell in front of node , and the node have a icon and how to add checkbox in head of the icon?
Download the DragNDropOutlineView sample code from Apple and have a look. It contains all the features you're looking for.
As for adding cells, think of it more in terms of adding columns (a column is designed to hold one cell of a single type). If you want more controls in each row, add a new column and set its cell type. Both of these actions can be performed easily in Interface Builder. You can select the table and increase its column count by one (a new column will appear), move the column where you want it (to the beginning), and drag a checkbox-configured button cell (there's a checkbox cell in the IB palette) into the body of the column and its "data cell" prototype will be set. That's it. Just wire it up as you normally would (NSTableViewDataSource or Cocoa Bindings) and you're done.