TableView objects are used to present hierarchical lists of information.
init(x, y, width, height, style)
initializes table view object with initial frame, where it will be displayed.
style - table style. Can be "grouped" or "plain"
shows control (not creating)
hides control (not destroying)
switches tableview to editing mode, where user can manipulate table rows, reorder and remove any rows. Parameter isEditing can be either "yes" or "no".
enables/disables ability to delete rows using swipe gestures, be default this is disabled.
inserts new category/section in table view with specified name
insertRecord(title, subtitle, image, sectionNumber, rightImage, callback)
inserts new row to the table.
title - rowʼs main title
subtitle - rowʼs subtitle, usually it is a description for the title
image - NKImage instance, which represents the image to be displayed in the left part of the row. Images larger then row height will be down scaled to row height. Images smaller then row height will appear at their original size.
sectionNumber - number of the section where the row must be inserted (starting from 0). rightImage - small image to be displayed in the right part of the row, usually showing that the item is clickable, if empty then default OSʼs action image will be used.
bindToDataBase(dbName, tableName, optionalQuery)
binds tableview to the given database using itʼs table as datasource, binding the database will destroy all the content in table view which was added earlier. optionalQuery is an optional parameter used to specify raw sql query to select table's content from database, for example: "SELECT * FROM products WHERE category='Fruits'". Of course you can use the query to load data sorted and to do other things which are allowed by SQL SELECT queries. To let NimbleKit know how data in a table view must be presented you need to have 6 columns in the database table, which are named exactly like following:
category - name of the category to which the row is related (for example "Fruits")
title - Rowʼs main title (for example "Apple")
subtitle - Rowʼs subtitle/description (for example "Nice green fruit")
image - the name of the image file which will be used in the left part of the row, can be the name from application bundle, documents folder or even an url to the image in the internet.
right_image - the image name if the small image to be displayed in the right part of the row, usually showing that the item is clickable, if empty then default OSʼs action image will be used. Can be the name from application bundle, documents folder or even an url to the image in the internet.
If you want to apply filter or resort data in table view you can call bindToDatabase multiple times with different "optionalQuery"s.
flushes changes made to the table view (using setEditing) into the database.
This method isnʼt must have, on application quit changes will be flushed anyway,
however different situations may occur.
This function works only if database has been bound to the table view.
Warning: if you quit iPhone simulator using CMD+Q then changes arenʼt written into the database, make sure youʼr either using commitDtaabaseChanges or quit simulator app using home button, this warning is only applies for iPhone/iPad simulator.
sets the row height for all rows in table.
height - rowʼs height in pixels
inserts array of records to the table
records - array of records
var tableView = new NKTableView(); tableView.init(20, 20, 280, 300, 'plain'); tableView.show(); tableView.insertCategoryNamed('FirstGroup'); tableView.insertCategoryNamed('SecondGroup'); var image = new NKImage(); image.loadFromBundle('arrow.png'); var firstRecord = new Object; firstRecord.title = "Record1"; firstRecord.subTitle = "subtitle" firstRecord.imageID = image.id;//note image ID is used firstRecord.rightImageID = image.id;//note image ID is used firstRecord.section = 0; firstRecord.callback = "onRowClick()"; var secondRecord = new Object; secondRecord.title = "Record2"; secondRecord.section = 1; var records = new Array();! records = firstRecord; records = secondRecord; tableView.insertRecords(records);