Class ::xo::Table::YUIDataTableRenderer (public)
::xotcl::Class ::xo::Table::YUIDataTableRenderer
Defined in
- Testcases:
-
No testcase defined.
Source code:
::nsf::object::alloc ::xotcl::Class ::xo::Table::YUIDataTableRenderer {set :__default_metaclass ::xotcl::Class
set :__default_superclass ::xotcl::Object}
::xo::Table::YUIDataTableRenderer instproc render {} {
::YUI::loader require -module "datatable"
if {![nsf::is object [self]::__actions]} {:actions {}}
if {![nsf::is object [self]::__bulkactions]} {:__bulkactions {}}
set bulkactions [[self]::__bulkactions children]
if {[[self]::__bulkactions exists __identifier] || [llength $bulkactions]>0} {
set name [[self]::__bulkactions set __identifier]
} else {
set name [::xowiki::Includelet js_name [self]]
}
set skin [expr {[info exists :skin] ? ${:skin} : ""}]
html::div -id ${:id}_wrapper -class $skin {
html::form -name $name -id $name -method POST {
html::div -id ${:id}_container {
html::table -id ${:id} -class ${:css.table-class} {
:render-actions
:render-body
}
if {[llength $bulkactions]>0} { :render-bulkactions }
}
}
::xo::Page requireJS "YAHOO.util.Event.onDOMReady(function () {\n[:render_yui_js]});"
}
}
::xo::Table::YUIDataTableRenderer instproc init_renderer {} {
next
set :css.table-class list-table
set :css.tr.even-class even
set :css.tr.odd-class odd
set :id [::xowiki::Includelet js_name [::xowiki::Includelet html_id [self]]]
}
::xo::Table::YUIDataTableRenderer instproc render_yui_js {} {
set container ${:id}_container
set datasource ${:id}_datasource
set datatable ${:id}_datatable
set coldef ${:id}_coldef
set finaljs ""
set js "var $datasource = new YAHOO.util.DataSource(YAHOO.util.Dom.get('${:id}')); \n"
append js "$datasource.responseType = YAHOO.util.DataSource.TYPE_HTMLTABLE; \n"
append js "$datasource.responseSchema = \{ \n"
append js " fields: \[ \n"
set js_fields [list]
foreach field [[self]::__columns children] {
if {[$field hide]} continue
lappend js_fields " \{ key: \"[$field set name]\" \}"
}
append js [join $js_fields ", "] " \] \n\};\n"
append js "var $coldef = \[\n"
set js_fields [list]
foreach field [[self]::__columns children] {
if {[$field hide]} continue
if {[$field istype HiddenField]} continue
if {[$field istype BulkAction]} {
set subid [::xowiki::Includelet html_id $field]
set label "<input type='checkbox' id='$subid'></input>"
if {[info exists ::__csrf_token]} {
append label "<input type='hidden' name='__csrf_token' value='$::__csrf_token'>"
}
set sortable false
append finaljs [subst {
document.getElementById('$subid').addEventListener('click', function (event) {
acs_ListCheckAll('objects', this.checked);
}, false);
}]
} else {
set label [lang::util::localize [$field label]]
set sortable [expr {[$field exists sortable] ? [$field set sortable] : true}]
}
lappend js_fields " \{ key: \"[$field set name]\" , sortable: $sortable, label: \"$label\" \}"
}
append js [join $js_fields ", "] "\];\n"
append js "var $datatable = new YAHOO.widget.DataTable('$container', $coldef, $datasource);\n"
append js $finaljs
return $js
}
::xo::Table::YUIDataTableRenderer instproc render-body {} {
html::thead {
html::tr -class list-header {
foreach o [[self]::__columns children] {
if {[$o hide]} continue
$o render
}
}
}
set children [:children]
html::tbody {
foreach line [:children] {
html::tr -class [expr {[incr :__rowcount]%2 ? ${:css.tr.odd-class} : ${:css.tr.even-class} }] {
foreach field [[self]::__columns children] {
if {[$field hide]} continue
html::td [concat [list class [concat list [$field CSSclass]]] [$field html]] {
$field render-data $line
}
}
}
}
}
}
::nsf::relation::set ::xo::Table::YUIDataTableRenderer superclass ::xo::Table::TABLE3
::nsf::object::alloc ::xotcl::Class ::xo::Table::YUIDataTableRenderer::Action {set :__default_metaclass ::xotcl::Class
set :__default_superclass ::xotcl::Object}
::nsf::relation::set ::xo::Table::YUIDataTableRenderer::Action superclass ::xo::Table::TABLE::Action
::nsf::object::alloc ::xotcl::Class ::xo::Table::YUIDataTableRenderer::ImageAnchorField {set :__default_metaclass ::xotcl::Class
set :__default_superclass ::xotcl::Object}
::nsf::relation::set ::xo::Table::YUIDataTableRenderer::ImageAnchorField superclass ::xo::Table::TABLE::ImageAnchorField
::nsf::object::alloc ::xotcl::Class ::xo::Table::YUIDataTableRenderer::AnchorField {set :__default_metaclass ::xotcl::Class
set :__default_superclass ::xotcl::Object}
::xo::Table::YUIDataTableRenderer::AnchorField instproc render-data line {
set __name ${:name}
if {[$line exists $__name.href] &&
[set href [$line set $__name.href]] ne ""} {
set CSSclass ${:CSSclass}
if {[$line exists $__name.CSSclass]} {
set lineCSSclass [$line set $__name.CSSclass]
if {$lineCSSclass ne ""} {
append CSSclass " " $lineCSSclass
}
}
$line instvar [list $__name.title title] [list $__name.target target] [list $__name.onclick onclick]
html::a [:get_local_attributes href title {CSSclass class} target onclick] {
return "[next]"
}
}
next
}
::nsf::relation::set ::xo::Table::YUIDataTableRenderer::AnchorField superclass ::xo::Table::TABLE::Field
::nsf::object::alloc ::xotcl::Class ::xo::Table::YUIDataTableRenderer::ImageField {set :__default_metaclass ::xotcl::Class
set :__default_superclass ::xotcl::Object}
::nsf::relation::set ::xo::Table::YUIDataTableRenderer::ImageField superclass ::xo::Table::TABLE::ImageField
::nsf::object::alloc ::xotcl::Class ::xo::Table::YUIDataTableRenderer::HiddenField {set :__default_metaclass ::xotcl::Class
set :__default_superclass ::xotcl::Object}
::nsf::relation::set ::xo::Table::YUIDataTableRenderer::HiddenField superclass ::xo::Table::TABLE::HiddenField
::nsf::object::alloc ::xotcl::Class ::xo::Table::YUIDataTableRenderer::BulkAction {set :__default_metaclass ::xotcl::Class
set :__default_superclass ::xotcl::Object}
::nsf::relation::set ::xo::Table::YUIDataTableRenderer::BulkAction superclass ::xo::Table::TABLE::BulkAction
::nsf::object::alloc ::xotcl::Class ::xo::Table::YUIDataTableRenderer::Field {set :__default_metaclass ::xotcl::Class
set :__default_superclass ::xotcl::Object}
::nsf::relation::set ::xo::Table::YUIDataTableRenderer::Field superclass ::xo::Table::TABLE::Field
namespace eval ::xo::Table {::namespace export Field AnchorField HiddenField Action ImageField ImageAnchorField ImageField_EditIcon ImageField_ViewIcon ImageField_DeleteIcon ImageField_AddIcon BulkAction}
XQL Not present:Generic, PostgreSQL, Oracle
[
hide source ]
| [
make this the default ]