- Methods: All Methods Documented Methods Hide Methods
- Source: Display Source Hide Source
- Variables: Show Variables Hide Variables
Class ::xo::Table::YUIDataTableRenderer
::xo::Table::YUIDataTableRenderer create ...
Defined in
Class Relations
::xotcl::Class create ::xo::Table::YUIDataTableRenderer \ -superclass ::xo::Table::TABLE3Methods (to be applied on instances)
init_renderer (scripted)
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]]]render (scripted)
::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]] } # TODO: maybe use skin everywhere? When to use style/CSSclass or skin? 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} { # TODO do i need that? :render-actions :render-body } if {[llength $bulkactions]>0} { :render-bulkactions } } } ::xo::Page requireJS "YAHOO.util.Event.onDOMReady(function () {\n[:render_yui_js]});" }render-body (scripted)
html::thead { html::tr -class list-header { foreach o [[self]::__columns children] { #ns_log notice "YUIDataTableRenderer $o [$o set name] HIDE [$o hide] RENDER [$o procsearch render]" 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 } } } } }render_yui_js (scripted, private)
<instance of xo::Table::YUIDataTableRenderer> render_yui_jsGenerates the JavaScript fragment, that is put below and (progressively enhances) the HTML table.
- Testcases:
- No testcase defined.
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
- Methods: All Methods Documented Methods Hide Methods
- Source: Display Source Hide Source
- Variables: Show Variables Hide Variables