HTML::FormFu::ExtJS::Element::SimpleTable - Simple table layout


HTML-FormFu-ExtJS documentation Contained in the HTML-FormFu-ExtJS distribution.

Index


Code Index:

NAME

Top

HTML::FormFu::ExtJS::Element::SimpleTable

VERSION

Top

version 0.090

DESCRIPTION

Top

This element renders a simple table using ExtJS column layout. There is no way to influence the width etc. of each column. They get distributed equally.

To create layouts with individual width and styles see HTML::FormFu::ExtJS::Element::Multi.

NAME

Top

HTML::FormFu::ExtJS::Element::SimpleTable - Simple table layout

SEE ALSO

Top

HTML::FormFu::Element::Multi

COPYRIGHT & LICENSE

Top

AUTHOR

Top

Moritz Onken <onken@netcubed.de>

COPYRIGHT AND LICENSE

Top


HTML-FormFu-ExtJS documentation Contained in the HTML-FormFu-ExtJS distribution.

#
# This file is part of HTML-FormFu-ExtJS
#
# This software is Copyright (c) 2011 by Moritz Onken.
#
# This is free software, licensed under:
#
#   The (three-clause) BSD License
#
package HTML::FormFu::ExtJS::Element::SimpleTable;
BEGIN {
  $HTML::FormFu::ExtJS::Element::SimpleTable::VERSION = '0.090';
}

use strict;
use warnings;
use utf8;

sub render {
	my $class = shift;
	my $self  = shift;
	my @header;
	my @rows;
	my $columns = 0;
	foreach my $element ( @{ $self->get_elements } ) {
		$columns = 0;
		foreach my $row ( @{ $element->get_elements } ) {
			if ( $row->tag eq "th" ) {
				push(
					@header,
					{
						xtype  => 'label',
						text   => scalar $row->{content},
						cls    => 'x-form-check-group-label',
						anchor => '-15',
					}
				);
			} elsif ( $row->tag eq "td" ) {
				push( @rows, @{ $self->form->_render_items($row) } );
				$columns++;
			}
		}
	}
	my $data;
	my $width = 1 / $columns;
	foreach my $i ( 0 .. $columns ) {
		my $column = { columnWidth => $width, layout => "form", items => [ ] };
		push( @{ $column->{items} }, $header[$i] ) if($header[$i]);
		foreach my $j ( 0 .. @rows - 1 ) {
			next unless ( $j % $columns == $i );
			push( @{ $column->{items} }, $rows[$j] );
		}
		push( @{$data}, $column );
	}
	pop( @{$data} );
	return { layout => "column", items => $data };
}
1;



__END__