everyone!
How to populate first column of nstableview with strings from array and the second column with strings from another array in dependence of selection in first column?
For example, look at the iTunes window, where the first column is selected playlist, and the second, a list of songs.
I could not find something like this on the internet.
I would be very grateful for the help.
This is little info about my model:
array with content for tableView populated with instances of NSObject sublass. This instances have three properties, to properties - NSString object, and last property an NSArray object with another strings. First and second properties used to populate first column, and i don't know how to populate sec on column with third property (strings from another array).
How to do this with bindings?
First of all: You do not populate columns, but rows. But reading your whole question, it seems to be that you understood this.
The solution is, that you do this with nested arrays and two table views:
Bindings:
A. The first table view gets the array of instances via an array controller that are on the top level of your model. Let's say "list of playlists". This array builds the rows for that table view with probably one column. The first column is bound to a property, likely "title".
playlistsArrayController.contentArray: somewhere.playlists
viewColumn.content: playlistsArrayController.arrangedObjects.title
B. Then you have a second table view with a second array controller. This is bound to the selection of the first one (playlists) and the property that contains the subentries, i. e. songs. This second array builds the rows of the second table view. Typically you have more columns there, every bound to a specific property ("title", "length", …)
songsArrayController.contentArray: playlistsArrayController.selection.songs
viewColumn1.content: songslistsArrayController.arrangedObjects.title
viewColumn2.content: songslistsArrayController.arrangedObjects.length
Both bindings are typed in Safari only for explanation.
Related
I'm using Handsontable and was able to fill a data grid with 16 rows and 9 columns retrieved from a database. Each cell represents a value from a table with a many to many relation. When saving the data-grid, an array is passed to view. I want to clearly identify each cell with the id provided from the table. Is this possible? I read about the setCellMeta(), but don't know how to apply this...
What you can do is iterate all cells and set metadata for each cell (rows and columns) with the value you need.
myhot.setCellMeta(0,0,'Id',1);// where parameters are: row, col,propertyName, value.
later you can do the following to read :
myhot.getCellMeta(0,0) // rown, col
I hope it helps
I have a flat file that I'm trying to transform into X12_00401_820. When I use the table looping and table extractor, the loop never happens.
Below is my map:
Below is the output. The invoice numbers are looping right, but I'm only getting the first amount, not the amount for each invoice.
The first input parameter to this functoid must be a scoping link, and
the second represents the number of columns in the data grid.
The first parameter of your functoid is the scope, you have to set your scope to SellersInvoiceNumber (don't link it graphically just write in input[0] SellersInvoiceNumber )
The second parameter of your functoid is the number of columns, you have to put 2 there as you will have two columns in your grid
So the third and fourth parameters will be your SellersInvoiceNumber and Invoice amount field (link it graphically as you already did)
Don't forget to configure your columns in the Table Looping Grid but i guess you've already done that
This should work
I have a tableview with one textboxcolumn and 7 checkbox columns.
This table will eventually be filled with data, and at some later point i have to remove one of the columns somewhere in the middle. What happens with the array associated with the table? How should i proprtly handle this? How would you do it? Please be clear in your answer since i am a beginner!
Have you learned how to provide data to the table view? I suggest getting that working before you try to solve this problem.
There are two ways to get data to the table view: a table view data source and Cocoa Bindings.
If you use a data source, you'll need to write -tableView:objectValueForTableColumn:row: so that it works correctly before or after the column is removed. One way to do this is to base that code on the column's identifier instead of its index. The identifier is a value you set on the column in your nib (look for Identifier). This is the same technique you can use to provide the correct data to reordered columns.
NSString *identifier = [column identifier];
if ([identifier isEqualToString:#"firstField"]) {
return ...
} else if ([identifier isEqualToString:#"secondField"]) {
return ...
}
If you use Cocoa Bindings, you can just remove a column and the other columns will keep working.
If you're using an array or an array controller, in neither case will anything automatically happen to the array when you remove a column.
I have this Birt report that I inherited from another developer, consisting of a child table inside a master table. For each row in the master table, the child table lists items belonging to the current master row item.
The two tables are fed from different data sets, the child table dataset taking a parameter indicating the master item whose child items to fetch.
Now, what I need to do is add a SUM aggregate to the bottom of the master table, showing the total (for all master items) of a certain field in the child table.
Consider, for example, the following data:
MasterItem1
ChildItem1 SomeValue
ChildItem2 SomeValue
ChildItem3 SomeValue
MasterItem2
ChildItem1 SomeValue
ChildItem2 SomeValue
ChildItem3 SomeValue
--------------------------------
Total
(Why wasn't this done with grouping instead? Short answer: There are in fact two child tables to each master row, containing different numers and types of fields, so the previous developer probably didn't figure out a way to accomplish this with grouping.)
At first I thought I could simply add another child table inside the Total field, with an aggregate summing up the values from the child dataset. That didn't work, however, since the child dataset requires a parameter indicating the master item whose children to fetch, so there is no way to get ALL values from the child dataset at once.
I'm thinking there might be a way to create an expression that references the SomeValue fields in the child table directly, instead of going through the child data set.
Any suggestions are greatly appreciated.
It should be possible to declare a global variable at the start of the report, then add each of the child values to it in one of the child table row events and output it at the end of the reports - if you're comfortable writing Javascript, this is probably the quickest solution.
If you're not comfortable writing Javascript (I'm not) or if the above technique doesn't work out, you could try either:
creating a third dataset, combining the master data items from the main report with the child data items from the subreport and outputting the total in a new data table, or
combining the two existing child data value tables via a union (so that if the master table is A, the main child table is B and the subreport table is C, you have AB union AC), replacing the subreport table and the existing detail rows with new detail rows conditional on child row type, and a total at the end of the report based on the AC values.
Obviously, the latter of these approaches is more complicated - but I think it should be easier to understand and maintain.
The Global Variable is the way to go. For each row in the child table, add the required value to the global variable and then access it for display at the bottom of the table. There is not any hard JavaScript:
var Sum = reportContext.getPersistentGlobalVariable( "RunningAggregate" );
Sum = Sum + row["column Name"];
reportContext.setPersistentGlobalVariable( "RunningAggregate", Sum );
You can then access the Global Variable in the footer of your table via a Dynamic Text item.
Good Luck!
Thanks Mark and Mystik, both your answers led me on the right path!
My final solution is as follows:
1) Declare the sum-variable in the initialize method for the report:
var total = 0;
2) Add each row's value to the sum-variable in the onReder method of the data field containing the values:
total += parseInt(this.getValue());
3) Use the sum-variable as expression in the total-field.
Works like a charm.
Update:
Found a bug in my solution: the last line was left out of the sum. I think the value of the total-cell in the table footer is being defined before the last line has been rendered.
Fix:
Moved summing code from onRender method to onCreate
Added the following code to the total-cell's onRender method:
this.setDisplayValue(total);
Thanks for the help.
I have a doc based Core Data app consisting of a table with two columns. The column cells are populated with US Currency dollar values. I have two labels at the bottom of each column with Number formatters. Each label displays the sum of it's respective column. I'm doing this with bindings:
Bound to the arrayController
Controller Key - arrangedObjects
modelKey - #sum.regAmount, #sum.regAmount1
The label attribute Types are int 16 in the data model.
Anyway, these calculations work fine, and the resulting values are displayed at startup.
What I need to do is also display the difference between the two resulting sums at startup in a third label. For some reason I can't pick up the sum values to preform the calculation.
This action works using a sender:
(runningBalance.intValue = (theDeposits.intValue - theAmounts.intValue));
How can I automatically display the calculated difference of the two sums at startup without manually executing the action?
Thanks again.
Paul
You don't need an action, you need a model key you can bind to just as you do with the sums. Then you bind that to the label's display(?) property and it should be called automatically.