Revision: 4726
Updated Code
at January 17, 2008 19:40 by Netzach
Updated Code
# What you NEED in the controller to be able to list someting in a NSTableView in RubyCocoa # # Creates the storage array, and another array which contains the names of the columns. def initialize @objects = Array.new @columns = ["Column Name 1", "Column Name 2", "Column Name 3", "Column Name 4"] end # Returns the numbers of rows in the array for NSTableView to display. def numberOfRowsInTableView(aTableView) return @objects.length end # Uses the @columns array to to enable a flexible number of columns when fetching data. def tableView_objectValueForTableColumn_row(afileTable, aTableColumn, rowIndex) @columns.each do |column| if aTableColumn.headerCell.stringValue == column object = @objects[rowIndex] return object[column] end end end # Usage: # # Creates the object that will go into the array. Mind you, the key values must be named the same way as the columns in the NSTableView, which is why it might be a good idea to use the actual @columns array post a identifiers. object = { @columns[0] => "Put...", @columns[1] => "...your...", @columns[2] => "...values...", @columns[3] => "...here" } # Adds the object to the @objects array @objects += [object] # Updates the NSTableView after a new post/row has been added to the storage array @tableViewOutlet.reloadData
Revision: 4725
Updated Code
at January 17, 2008 19:33 by Netzach
Updated Code
# What you NEED in the controller to be able to list someting in a NSTableView in RubyCocoa # # Creates the storage array, and another array which contains the names of the columns. def initialize @objects = Array.new @columns = ["Column Name 1", "Column Name 2", "Column Name 3", "Column Name 4"] end # Returns the numbers of rows in the array for NSTableView to display. def numberOfRowsInTableView(aTableView) return @objects.length end # Uses the @columns array to to enable a flexible number of columns when fetching data. def tableView_objectValueForTableColumn_row(afileTable, aTableColumn, rowIndex) @columns.each do |column| if aTableColumn.headerCell.stringValue == column object = @objects[rowIndex] return object[column] end end end # Usage: # # Creates the object that will go into the array. Mind you, the key values must be named the same way as the columns in the NSTableView, which is why it might be a good idea to use the actual @columns array post a identifiers. object = { @columns[0] => "Put...", @columns[1] => "...your...", @columns[2] => "...values...", @columns[3] => "...here" } # Adds the object to the @objects array @objects += [object]
Revision: 4724
Updated Code
at January 17, 2008 19:32 by Netzach
Updated Code
# What you NEED in the controller to be able to list someting in a NSTableView in RubyCocoa # # Creates the storage array, and another array which contains the names of the columns. def initialize @objects = Array.new @columns = ["Column Name 1", "Column Name 2", "Column Name 3", "Column Name 4"] end # Returns the numbers of rows in the array for NSTableView to display. def numberOfRowsInTableView(aTableView) return @objects.length end # Uses the @columns array to to enable a flexible number of columns when fetching data. def tableView_objectValueForTableColumn_row(afileTable, aTableColumn, rowIndex) @columns.each do |column| if aTableColumn.headerCell.stringValue == column object = @objects[rowIndex] return object[column] end end end # Usage: # # Creates the object that will go into the array. Mind you, the key values must be named the same way as the columns in the NSTableView, which is why it might be a good idea to use the actual @columns array post a identifiers. row = { @columns[0] => "Put...", @columns[1] => "...your...", @columns[2] => "...values...", @columns[3] => "...here" } # Adds the object to the array @objects += [row]
Revision: 4723
Updated Code
at January 17, 2008 19:31 by Netzach
Updated Code
# What you NEED in the controller to be able to list someting in a NSTableView in RubyCocoa # # Creates the storage array, and another array which contains the names of the columns. def initialize @objects = Array.new @columns = ["Column Name 1", "Column Name 2", "Column Name 3", "Column Name 4"] end # Returns the numbers of rows in the array for NSTableView to display. def numberOfRowsInTableView(aTableView) return @objects.length end # Uses the @columns array to to enable a flexible number of columns when fetching data. def tableView_objectValueForTableColumn_row(afileTable, aTableColumn, rowIndex) @columns.each do |column| if aTableColumn.headerCell.stringValue == column object = @objects[rowIndex] return object[column] end end end # Usage: # # Creates the object that will go into the array. Mind you, the key values must be named the same way as the columns in the NSTableView, which is why it might be a good idea to use the actual @columns array post a identifiers. row = { @columns[0] => "Put...", @columns[1] => "...your...", @columns[2] => "...values...", @columns[3] => "...here" } # Adds the object to the array @persons += [row]
Revision: 4722
Updated Code
at January 17, 2008 19:30 by Netzach
Updated Code
# What you NEED in the controller to be able to list someting in a NSTableView in RubyCocoa # # Creates the storage array, and another array which contains the names of the columns. def initialize @objects = Array.new @columns = ["Column Name 1", "Column Name 2", "Column Name 3", "Column Name 4"] end # Returns the numbers of rows in the array for NSTableView to display. def numberOfRowsInTableView(aTableView) return @objects.length end # Uses the @columns array to to enable a flexible number of columns when fetching data. def tableView_objectValueForTableColumn_row(afileTable, aTableColumn, rowIndex) @columns.each do |column| if aTableColumn.headerCell.stringValue == column object = @objects[rowIndex] return object[column] end end end # Usage: # # Creates the object that will go into the array. Mind you, the key values must be named the same way as the columns in the NSTableView, which is why it might be a good idea to use the actual column array post. row = { @columns[0] => "Put...", @columns[1] => "...your...", @columns[2] => "...values...", @columns[3] => "...here" } # Adds the object to the array @persons += [row]
Revision: 4721
Updated Code
at January 17, 2008 19:28 by Netzach
Updated Code
# What you NEED in the controller to be able to list someting in a NSTableView in RubyCocoa # # Creates the storage array, and another array which contains the names of the columns. def initialize @objects = Array.new @columns = ["Column Name 1", "Column Name 2", "Column Name 3", "Column Name 4"] end # Returns the numbers of rows in the array for NSTableView to display. def numberOfRowsInTableView(aTableView) return @objects.length end # Uses the @columns array to to enable a flexible number of columns when fetching data. def tableView_objectValueForTableColumn_row(afileTable, aTableColumn, rowIndex) @columns.each do |column| if aTableColumn.headerCell.stringValue == column object = @objects[rowIndex] return object[column] end end end # Usage: # # Creates the object that will go into the array. Mind you, the key values must be named the same way as the columns in the NSTableView. row = { "Column Name 1" => "Put...", "Column Name 2" => "...your...", "Column Name 3" => "...values...", "Column Name 4" => "...here" } # Adds the object to the array @persons += [row]
Revision: 4720
Updated Code
at January 17, 2008 19:27 by Netzach
Updated Code
# What you NEED in the controller to be able to list someting in a NSTableView in RubyCocoa # # Creates the storage array, and another array which contains the names of the columns. def initialize @objects = Array.new @columns = ["Column Name 1", "Column Name 2", "Column Name 3", "Column Name 4"] end # Returns the numbers of rows in the array for NSTableView to display. def numberOfRowsInTableView(aTableView) return @persons.length end # Uses the @columns array to to enable a flexible number of columns when fetching data. def tableView_objectValueForTableColumn_row(afileTable, aTableColumn, rowIndex) @columns.each do |column| if aTableColumn.headerCell.stringValue == column object = @objects[rowIndex] return object[column] end end end # Usage: # # Creates the object that will go into the array. Mind you, the key values must be named the same way as the columns in the NSTableView. row = { "Column Name 1" => "Put...", "Column Name 2" => "...your...", "Column Name 3" => "...values...", "Column Name 4" => "...here" } # Adds the object to the array @persons += [row]
Revision: 4719
Updated Code
at January 17, 2008 19:24 by Netzach
Updated Code
# What you NEED in the controller to be able to list someting in a NSTableView in RubyCocoa # # Creates the storage array, and another array which contains the names of the columns. def initialize @objects = Array.new @columns = ["Column Name 1", "Column Name 2", "Column Name 3", "Column Name 4"] end # Returns the numbers of rows in the array for NSTableView to display. def numberOfRowsInTableView(aTableView) return @persons.length end # Uses the @columns array to to enable a flexible number of columns when fetching data. def tableView_objectValueForTableColumn_row(afileTable, aTableColumn, rowIndex) @columns.each do |column| if aTableColumn.headerCell.stringValue == column object = @objects[rowIndex] return object[column] end end end # Usage: # # Creates the object that will go into the array. Mind you, the key values must be named the same way as the columns in the NSTableView. row = { "Column Name 1" => "Put...", "Column Name 2" => "...your...", "Column Name 3" => "...values...", "Column Name 4" => "...here" } # Adds the object to the array @persons += [row]
Revision: 4718
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at January 17, 2008 19:23 by Netzach
Initial Code
Initial URL
Initial Description
Initial Title
RubyCocoa control methods for a four column NSTableView
Initial Tags
textmate, ruby
Initial Language
Ruby