Alien-GvaScript
view release on metacpan or search on metacpan
src/grid.js view on Meta::CPAN
this.actionButtons = new GvaScript.CustomButtons.ButtonNavigation(this.actionsbar_container, {
selectFirstBtn: false,
className: bcss+'-btn-container'
});
},
// wrapping the recordset in a table with column headers
gridWrapper: function(html) {
return '<table class="'+bcss+'-grid '+this.options.css+'">' +
'<thead><tr>' +
'<th class="grid-marker"> </th>' +
(this.columns.collect(function(e) {
if(_evalCondition(e, this))
return '<th class="grid-header'+_compileCss(e)+'"'+_compileWidth(e)+_compileTitle(e)+'>'+e.label+'</th>'
else return '';
}, this).join('')) +
'</tr></thead>' +
'<tbody>'+html+'</tbody>'+
'</table>';
},
// called by the paginator
receiveRequest: function(response_json) {
this.records = response_json.liste;
this.total = response_json.total;
this.rights = response_json.rights || {can_create: 1};
var list_records = $A(this.records).collect(function(e, index) {
return '<td class="grid-marker"> </td>' +
this.columns.collect(function(c) {
if(_evalCondition(c, this))
return '<td class="grid-cell index_'+(index%2)+_compileCss(c)+'" valign="top">' +
_getColumnValue(c, e) +
'</td>';
else return '';
}, this).join('');
}, this);
// TODO not elegant !
if(this.choiceList_initialized) {
this.choiceList.updateContainer(this.grid_container, list_records);
}
else {
this.choiceList.choices = list_records;
this.choiceList.fillContainer(this.grid_container);
this.choiceList_initialized = true;
}
if(this.options.grabfocus) {
try {this.grid_container.focus();}
catch(e) {}
}
if(typeof this.actionButtons == 'undefined')
this.addActionButtons();
if(!(this.total > 0)) this.options.onEmpty.apply(this);
(this.options.onShow || Prototype.emptyFunction).call();
return this.records.length;
}
}
}());
// registers all grids
GvaScript.Grids = {
grids: $A(),
register: function(grid) {
this.unregister(grid);
this.grids.push(grid);
},
unregister: function(grid) {
// nothing to unregister
if(!grid) return;
if(typeof grid == 'string') grid = this.get(grid);
// nothing to unregister
if(!grid) return false;
// remove the reference from array
this.grids = this.grids.reject(function(g) { return g.getId() == grid.getId() });
return true;
},
get: function(id) {
return this.grids.find(function(g) {return g.getId() == id});
}
}
( run in 0.689 second using v1.01-cache-2.11-cpan-02777c243ea )