Class name

E.controls.datatable (0.1.0)

Methods

Method Parameters Returns Description Example
build string Build string of component markup build()
append jquery selector boolean Build and append string to DOM append('#mydiv')
columns array this Set all column headers columns( [ 'Name', 'Email' ] )
column string this Add a column header column('Name')
items array this Set entire dataset for the view items( [ [], ..., [] ] )
item array this Append individual row item( [ ... ] )
pagesize positive integer this Number of items per page (default is 10) pagesize(6)

Note

For the purposes of this documentation, we are using a remote data source of generated random data.
Sample data
[
	{
		"id": 1,
		"gender": "Male",
		"first_name": "Keith",
		"last_name": "Kennedy",
		"color": "Red",
		"country": "CN",
		"joined": "2015-05-22"
	}
]

Usage

Load data and create control

$.getJSON( 'demodata.js', function( d ) {
	// make sure data is present
	if( d ) {
		// create instance of control
		var o = $E('datatable');
		// set page size
		o.pagesize(15);
		// set colum headers
		o.columns( [ 'Name', 'Gender', 'Color', 'Joined' ] );
		// set data
		for( var i in d )
			o.item( [
				d[i].first_name + ' ' + d[i].last_name,
				d[i].gender,
				'<span style="color:' + d[i].color + ';">' + d[i].color + '</span>',
				d[i].joined
			] );
		}
		// append to DOM
		o.append('#mydiv');
	}
} );
Last modified: 2016-02-19