plugins/bootstrap/datatable.js
function ElementDataSource(config) {
	var newData = [],
		newColumns = [];

	var headings = config.data.all('tr th');

	headings.each(function(th){
		newColumns.push(th.getHtml());
	});

	config.data.all('tr').each(function(tr){
		var newRow = {},
			populated = false;

		for (var i = 0, numCols = headings.size(); i < numCols; i++) {

			if (!tr.all('td').item(i)) { continue; }

			newRow[headings.item(i).getHtml()] = tr.all('td').item(i).getHtml();
			populated = true;
		}

		if (populated) {
			newData.push(newRow);
		}
	});

	config.columns = newColumns;
	config.data = newData;

	return new JSONDataSource(config);
}
function ElementDataSource(config) {
	var newData = [],
		newColumns = [];

	var headings = config.data.all('tr th');

	headings.each(function(th){
		newColumns.push(th.getHtml());
	});

	config.data.all('tr').each(function(tr){
		var newRow = {},
			populated = false;

		for (var i = 0, numCols = headings.size(); i < numCols; i++) {

			if (!tr.all('td').item(i)) { continue; }

			newRow[headings.item(i).getHtml()] = tr.all('td').item(i).getHtml();
			populated = true;
		}

		if (populated) {
			newData.push(newRow);
		}
	});

	config.columns = newColumns;
	config.data = newData;

	return new JSONDataSource(config);
}
function ElementDataSource ( config ) { var newData = [ ] , newColumns = [ ] ; var headings = config . data . all ( 'tr th' ) ; headings . each ( function ( th ) { newColumns . push ( th . getHtml ( ) ) ; } ) ; config . data . all ( 'tr' ) . each ( function ( tr ) { var newRow = { } , populated = false ; for ( var i = 0 , numCols = headings . size ( ) ; i < numCols ; i ++ ) { if ( ! tr . all ( 'td' ) . item ( i ) ) { continue ; } newRow [ headings . item ( i ) . getHtml ( ) ] = tr . all ( 'td' ) . item ( i ) . getHtml ( ) ; populated = true ; } if ( populated ) { newData . push ( newRow ) ; } } ) ; config . columns = newColumns ; config . data = newData ; return new JSONDataSource ( config ) ; }
All we do is transform the table into json and reutrn a JSONDataSource
All we do is transform the table into json and reutrn a JSONDataSource