[#48,refactor][s]: rename DataTable to DataGrid - fixes #48.
This commit is contained in:
@@ -6,7 +6,7 @@ $(function() {
|
|||||||
{
|
{
|
||||||
id: 'grid',
|
id: 'grid',
|
||||||
label: 'Grid',
|
label: 'Grid',
|
||||||
view: new recline.View.DataTable({
|
view: new recline.View.DataGrid({
|
||||||
model: dataset
|
model: dataset
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -79,9 +79,9 @@
|
|||||||
<li>Pure javascript (no Flash) and designed for integration -- so it is
|
<li>Pure javascript (no Flash) and designed for integration -- so it is
|
||||||
easy to embed in other sites and applications</li>
|
easy to embed in other sites and applications</li>
|
||||||
<li>Open-source</li>
|
<li>Open-source</li>
|
||||||
<li>Built on <a
|
<li>Built on the simple but powerful <a
|
||||||
href="http://documentcloud.github.com/backbone/">Backbone</a> - so
|
href="http://documentcloud.github.com/backbone/">Backbone</a> giving a
|
||||||
robust design and extremely easy to exend</li>
|
clean and robust design which is easy to extend</li>
|
||||||
<li>Properly designed model with clean separation of data and presentation</li>
|
<li>Properly designed model with clean separation of data and presentation</li>
|
||||||
<li>Componentized design means you use only what you need</li>
|
<li>Componentized design means you use only what you need</li>
|
||||||
</ul>
|
</ul>
|
||||||
@@ -114,7 +114,7 @@
|
|||||||
<p>There are then various Views (you can easily write your own). Each view holds a pointer to a Dataset:</p>
|
<p>There are then various Views (you can easily write your own). Each view holds a pointer to a Dataset:</p>
|
||||||
<ul>
|
<ul>
|
||||||
<li>DataExplorer: the parent view which manages the overall app and sets up sub views.</li>
|
<li>DataExplorer: the parent view which manages the overall app and sets up sub views.</li>
|
||||||
<li>DataTable: the data grid / table view.</li>
|
<li>DataGrid: the data grid view.</li>
|
||||||
<li>FlotGraph: a simple graphing view using <a href="http://code.google.com/p/flot/">Flot</a>.</li>
|
<li>FlotGraph: a simple graphing view using <a href="http://code.google.com/p/flot/">Flot</a>.</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ this.recline = this.recline || {};
|
|||||||
this.recline.View = this.recline.View || {};
|
this.recline.View = this.recline.View || {};
|
||||||
|
|
||||||
(function($, my) {
|
(function($, my) {
|
||||||
// ## DataTable
|
// ## DataGrid
|
||||||
//
|
//
|
||||||
// Provides a tabular view on a Dataset.
|
// Provides a tabular view on a Dataset.
|
||||||
//
|
//
|
||||||
@@ -10,8 +10,8 @@ this.recline.View = this.recline.View || {};
|
|||||||
//
|
//
|
||||||
// Additional options passed in second arguments. Options:
|
// Additional options passed in second arguments. Options:
|
||||||
//
|
//
|
||||||
// * cellRenderer: function used to render individual cells. See DataTableRow for more.
|
// * cellRenderer: function used to render individual cells. See DataGridRow for more.
|
||||||
my.DataTable = Backbone.View.extend({
|
my.DataGrid = Backbone.View.extend({
|
||||||
tagName: "div",
|
tagName: "div",
|
||||||
className: "data-table-container",
|
className: "data-table-container",
|
||||||
|
|
||||||
@@ -205,7 +205,7 @@ my.DataTable = Backbone.View.extend({
|
|||||||
this.model.currentDocuments.forEach(function(doc) {
|
this.model.currentDocuments.forEach(function(doc) {
|
||||||
var tr = $('<tr />');
|
var tr = $('<tr />');
|
||||||
self.el.find('tbody').append(tr);
|
self.el.find('tbody').append(tr);
|
||||||
var newView = new my.DataTableRow({
|
var newView = new my.DataGridRow({
|
||||||
model: doc,
|
model: doc,
|
||||||
el: tr,
|
el: tr,
|
||||||
fields: self.fields,
|
fields: self.fields,
|
||||||
@@ -219,10 +219,10 @@ my.DataTable = Backbone.View.extend({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// ## DataTableRow View for rendering an individual document.
|
// ## DataGridRow View for rendering an individual document.
|
||||||
//
|
//
|
||||||
// Since we want this to update in place it is up to creator to provider the element to attach to.
|
// Since we want this to update in place it is up to creator to provider the element to attach to.
|
||||||
// In addition you must pass in a fields in the constructor options. This should be list of fields for the DataTable.
|
// In addition you must pass in a fields in the constructor options. This should be list of fields for the DataGrid.
|
||||||
//
|
//
|
||||||
// Additional options can be passed in a second hash argument. Options:
|
// Additional options can be passed in a second hash argument. Options:
|
||||||
//
|
//
|
||||||
@@ -231,7 +231,7 @@ my.DataTable = Backbone.View.extend({
|
|||||||
// corresponding field object and document is the document object. Note
|
// corresponding field object and document is the document object. Note
|
||||||
// that implementing functions can ignore arguments (e.g.
|
// that implementing functions can ignore arguments (e.g.
|
||||||
// function(value) would be a valid cellRenderer function).
|
// function(value) would be a valid cellRenderer function).
|
||||||
my.DataTableRow = Backbone.View.extend({
|
my.DataGridRow = Backbone.View.extend({
|
||||||
initialize: function(initData, options) {
|
initialize: function(initData, options) {
|
||||||
_.bindAll(this, 'render');
|
_.bindAll(this, 'render');
|
||||||
this._fields = initData.fields;
|
this._fields = initData.fields;
|
||||||
|
|||||||
@@ -23,14 +23,14 @@ this.recline.View = this.recline.View || {};
|
|||||||
//
|
//
|
||||||
// **views**: (optional) the views (Grid, Graph etc) for DataExplorer to
|
// **views**: (optional) the views (Grid, Graph etc) for DataExplorer to
|
||||||
// show. This is an array of view hashes. If not provided
|
// show. This is an array of view hashes. If not provided
|
||||||
// just initialize a DataTable with id 'grid'. Example:
|
// just initialize a DataGrid with id 'grid'. Example:
|
||||||
//
|
//
|
||||||
// <pre>
|
// <pre>
|
||||||
// var views = [
|
// var views = [
|
||||||
// {
|
// {
|
||||||
// id: 'grid', // used for routing
|
// id: 'grid', // used for routing
|
||||||
// label: 'Grid', // used for view switcher
|
// label: 'Grid', // used for view switcher
|
||||||
// view: new recline.View.DataTable({
|
// view: new recline.View.DataGrid({
|
||||||
// model: dataset
|
// model: dataset
|
||||||
// })
|
// })
|
||||||
// },
|
// },
|
||||||
@@ -101,7 +101,7 @@ my.DataExplorer = Backbone.View.extend({
|
|||||||
this.pageViews = [{
|
this.pageViews = [{
|
||||||
id: 'grid',
|
id: 'grid',
|
||||||
label: 'Grid',
|
label: 'Grid',
|
||||||
view: new my.DataTable({
|
view: new my.DataGrid({
|
||||||
model: this.model
|
model: this.model
|
||||||
})
|
})
|
||||||
}];
|
}];
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
module("View");
|
module("View");
|
||||||
|
|
||||||
test('new DataTableRow View', function () {
|
test('new DataGridRow View', function () {
|
||||||
var $el = $('<tr />');
|
var $el = $('<tr />');
|
||||||
$('.fixtures .test-datatable').append($el);
|
$('.fixtures .test-datatable').append($el);
|
||||||
var doc = new recline.Model.Document({
|
var doc = new recline.Model.Document({
|
||||||
@@ -10,7 +10,7 @@ test('new DataTableRow View', function () {
|
|||||||
'b': '2',
|
'b': '2',
|
||||||
'a': '1'
|
'a': '1'
|
||||||
});
|
});
|
||||||
var view = new recline.View.DataTableRow({
|
var view = new recline.View.DataGridRow({
|
||||||
model: doc
|
model: doc
|
||||||
, el: $el
|
, el: $el
|
||||||
, fields: new recline.Model.FieldList([{id: 'a'}, {id: 'b'}])
|
, fields: new recline.Model.FieldList([{id: 'a'}, {id: 'b'}])
|
||||||
@@ -21,7 +21,7 @@ test('new DataTableRow View', function () {
|
|||||||
equal(tds.length, 3);
|
equal(tds.length, 3);
|
||||||
equal($(tds[1]).attr('data-field'), 'a');
|
equal($(tds[1]).attr('data-field'), 'a');
|
||||||
|
|
||||||
var view = new recline.View.DataTableRow({
|
var view = new recline.View.DataGridRow({
|
||||||
model: doc
|
model: doc
|
||||||
, el: $el
|
, el: $el
|
||||||
, fields: new recline.Model.FieldList([{id: 'a'}, {id: 'b'}])
|
, fields: new recline.Model.FieldList([{id: 'a'}, {id: 'b'}])
|
||||||
|
|||||||
Reference in New Issue
Block a user