Skip to content

Commit f8e3e3b

Browse files
improving table config api
1 parent 88ebe8e commit f8e3e3b

File tree

2 files changed

+19
-13
lines changed

2 files changed

+19
-13
lines changed

lib/viewer/tableConfig.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,11 +209,23 @@ WOQLTableRule.prototype.minWidth = function(wid){
209209
return this;
210210
}
211211

212+
WOQLTableRule.prototype.sortable = function(sortable){
213+
if(typeof sortable == "undefined"){
214+
return this.rule.sortable;
215+
}
216+
this.rule.sortable = sortable;
217+
return this;
218+
}
219+
220+
212221
WOQLTableRule.prototype.prettyPrint = function(type){
213222
var str = Config.WOQLViewRule.prototype.prettyPrint.apply(this);
214223
if(typeof this.header() != "undefined"){
215224
str += ".header(" + this.header() + ")";
216225
}
226+
if(this.sortable()){
227+
str += ".sortable(true)";
228+
}
217229
if(typeof this.width() != "undefined"){
218230
str += ".width(" + this.width() + ")";
219231
}

lib/viewer/woqlTable.js

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -91,15 +91,6 @@ WOQLTable.prototype.getColumnsToRender = function(){
9191
return (cols ? cols.filter(col => !self.hidden(col)) : []);
9292
}
9393

94-
WOQLTable.prototype.isSortableColumn = function(){
95-
return true
96-
}
97-
98-
WOQLTable.prototype.isFilterableColumn = function(){
99-
return true
100-
}
101-
102-
10394
WOQLTable.prototype.getColumnHeaderContents = function(colid){
10495
colid = UTILS.removeNamespaceFromVariable(colid);
10596
let hr = new WOQLRule().matchColumn(this.config.rules, colid, "header");
@@ -205,10 +196,8 @@ WOQLTable.prototype.hasCellHover = WOQLTable.prototype.getCellHover;
205196
WOQLTable.prototype.hasRowHover = WOQLTable.prototype.getRowHover;
206197

207198
WOQLTable.prototype.getRenderer = function(key, row, rownum){
208-
var rend = this.getSpecificRender(key, row);
209-
if(rend) return rend;
210-
let renderer = this.getDefinedEvent(row, key, "column", "renderer", rownum);
211-
let args = this.getDefinedEvent(row, key, "column", "args", rownum);
199+
return this.getDefinedEvent(row, key, "column", "renderer", rownum);
200+
//let args = this.getDefinedEvent(row, key, "column", "args", rownum);
212201
if(!renderer){
213202
let r = this.getRendererForDatatype(row[key]);
214203
renderer = r.name;
@@ -219,6 +208,11 @@ WOQLTable.prototype.getRenderer = function(key, row, rownum){
219208
}
220209
}
221210

211+
WOQLTable.prototype.isSortableColumn = function(key){
212+
return this.getDefinedEvent(false, key, "column", "sortable") || false
213+
}
214+
215+
222216
WOQLTable.prototype.renderValue = function(renderer, val, key, row){
223217
if(val && val['@type']){
224218
renderer.type = val['@type'];

0 commit comments

Comments
 (0)