How would you make a text cell in a an Outline View show how many children the parent row has? - objective-c

How would you make Rows that are the Top Parent in an Outline View (which is connected to a NSTreeController) display how many children it has in a Text Cell?
If this is a bit confusing here is a Picture of what I mean.
(source: sourceforge.net)
I am talking about the number to the right of one of the rows in the circle, which is displaying how many children the parent has.

You can either make a custom NSCell subclass that will show the child count (you would use your model object itself as the cell's object value, instead of providing a separate string or image), or in your data source method for the outline view you could just include the count along with the title string. Of course, you'll have to use the first option if you want it drawn exactly like the screenshot.

Custom cell, either on that column or on a second column.

Related

How to add button for each row in table?

Labview,
i would like to add button for each row in table and this button depends on number of rows of data in the table,Button will add programatically in each row.
Reference Image: Cross button
When do you say "Table", Are you referring to "Multi-Column ListBox" or "Table Control" or Individual 1D arrays that are arranged like a Table? There are many ways you can do this!
An array of Clusters as Dave_St suggested.
Using a Table control & Boolean Array.
Using a Table control & Array of Picture Ring.
Using individual 1D Arrays Arranged like a Table.
I'd recommend the first method. Since it makes data handling pretty easy!
But If you're going to go with any other method! You can make your boolean array background as white/transparent and place on top of a Table Column!
Example:
In the above image, I used a Table Control and an array of Picture ring. But you need to synchronize both your array's scrolling positions! Only then the user shall be able to see the correct status for the row.
It seems like you're trying to imitate a webpage form! If you want to dynamically add controls/indicators to your VI check out VI Scripting! But I'm not sure whether VI Scripting will satisfy your requirement.
There are a couple of other ways to get this behavior. However, the array of clusters is probably the easiest. Two other ways to do it are:
Use the glyph (symbol) functionality of a table or multicolumn listbox
Create a data grid or use the DataGrid QControl.
P.S. You currently cannot programmatically add controls/indicators during run time. So VI Scripting won't help you there.

A proper way to reduce provided data set in UITableViewController

I am provided a reference to a NSArray that contains data items. In my Custom View controller that acts as a data source for the table view, I interpret each item and present it as a cell.
So far so good.
Now there is a requirement from my colleagues to implement a filter, that will be based on values of one of the item's properties.
This property has enumerated values (4 of them). So when I apply the filter, i should see only items that match the particular value.
My question is how should I approach this filtering of that data.
1) Should I set the _data private variable to point to the original data source, and then override the "data" property getter to take into account the filtering?
2) Should I generate a separate filteredData array inside my controller?
3) Some other approach?
NOTE> coredata+fetched resultscontr. is out of the question. The number of items never will be more then 150-200.
I would go with the second choice. Having a filteredDatasource is more convenient. This way, you are able to know , not only the cells you should display, but also how many they are etc. Moreover, if in the future you want to sort them and use sections, you will be far more flexible.
For example when you implement the method – tableView:numberOfRowsInSection: which is called many times internally using the filtered data source you do not have to traverse through the array's objects many times so as to see which of them should pass the filter. You just return [filteredDatasource count]. This is more efficient.
In the apps I work on we have a array of all items and a copy which is the one the datasource refers to. When a filter is applied it replaces the copy but is based on the original array. So I guess #2.

How to make two text fields in one container like this?

How to make two text fields like middle screen in this picture:
Of course in this sample it list, with Labels, but I want make simulate control with TextFields. How I can make this?
it's a tableview with the style is group, and have a hardview in table, one section with three cells

How do I select all selected checkboxes in the NSOutlineView

I have NSOutlineView with checkboxes:
When I select multiple rows they become blue, however if I check any checkbox, I only select the related item (and its children).
Instead, I would like to check all selected items in the table.
Thanks
Here's a solution:
Create an action in your view controller to handle the new behavior.
Connect your NSButtonCell's action selector to this action.
In the new action, you need to propagate the cell's value to the rest of the selected rows. Call -numberOfSelectedRows on your outline view to find out if there are any more rows you need to act on, and -selectedRowIndexes to get access to the row indexes.
After you make the changes to the fields in the model, depending on how your outline view gets its data, you may need to call -reloadData to update the display of the other rows.

Retaining table view cell's text field data

How to retain table cell's text field data entered by the user after user scroll the table view or comes back the to table after navigating to another view?
i'm working on an iPhone app which has a table containing labels and text fields in its cells
. after filling the text fields whenever i scroll the dat in the text fields comes to blank.
plz help me .
Take Dictionary and save values of the textfields with key values as indexpaths ,
in cellforrow delegate method, display textfield data retrieving from the dictionary.
In textfileddidendediting delegate method, save the value of textfield to the dictionary.
Or else you can use array also to save values.
You need to follow MVC: keep the underlying model data separately from it's view representation.
If your data is a string per table row, then create an NSMutableArray to hold the NSStrings returned from your UITextField.text values.
Expanding to fill in some basic details: UITableViewCells can be reused for efficiency. That's what the docs say. Which means that, as soon as a cell is no longer visible, it is a candidate for reuse. The UITableView structure is a view layer component; the strings that you keep in it are your "model". They should be maintained separately.
So, rather than attempting to store your strings in the table cells, which is a bad idea AND won't work, construct an array of strings that you can display in the UITextField that you have added to the cells. A dictionary is an alternative data structure to hold your strings, but if you are following the linear nature of a table view, it seems unlikely that using a dictionary keyed with your row indexes will have any advantage over an array.