Permalink
Browse files

bugfixes to empty message functionality

 + change empty message once it has already been set
 + show the header correctly when table is empty
 + added empty message thing to demo page
  • Loading branch information...
1 parent e69cf2b commit 04d4208a277b98c794d65f2eb42b918e94ec79b4 @reednj committed Aug 28, 2011
Showing with 16 additions and 4 deletions.
  1. +11 −1 Source/jsTable.js
  2. +1 −1 Test/demo.html
  3. +4 −2 Test/test.html
View
12 Source/jsTable.js
@@ -86,7 +86,11 @@ var jsTable = new Class({
},
_createEmptyMessage: function() {
- this.empty_tr = $e('div', {'class':'jst-emptymessage', 'text': this.options.empty_message});
+ this.empty_tr = $e('div', {
+ 'class':'jst-emptymessage',
+ 'text': this.options.empty_message
+ });
+
this.element.grab(this.empty_tr);
// show we be showing the message or not?
@@ -103,13 +107,17 @@ var jsTable = new Class({
if(this.options.show_header_onempty !== true) {
this.thead.show();
+ } else {
+ this.thead.show();
}
} else if(this.data.length == 0 && this.empty_tr.getStyle('display') != '') {
this.empty_tr.show();
if(this.options.show_header_onempty !== true) {
this.thead.hide();
+ } else {
+ this.thead.show();
}
}
},
@@ -144,6 +152,8 @@ var jsTable = new Class({
// element and add it to the page.
if(!$defined(this.empty_tr)) {
this._createEmptyMessage();
+ } else {
+ this.empty_tr.innerHTML = this.options.empty_message;
}
return this;
View
2 Test/demo.html
@@ -64,7 +64,7 @@
},
create_t1: function() {
- this.jst = new jsTable('t1');
+ this.jst = new jsTable('t1', {'empty_message': 'Click the link above to add rows'});
this.jst.addColumn('ID');
this.jst.addColumn('N1');
this.jst.addColumn('N2');
View
6 Test/test.html
@@ -52,9 +52,11 @@
var jst = this.jst;
- jst.addColumn('id', 'id').addColumn('desc', 'Description').addColumn('button', 'delete').setEmptyMessage('test', true);
+ jst.addColumn('id', 'id').addColumn('desc', 'Description').addColumn('button', 'delete');
- //jst.setEmptyMessage('empty table', true);
+ if(Math.random() > 0.5) {
+ jst.setEmptyMessage('empty table', true);
+ }
for(i=0; i < 10; i++) {
var id = (Math.random() * 100).round();

0 comments on commit 04d4208

Please sign in to comment.