HTML::FormFu::ExtJS::Element::ComboBox - An editable select box


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

Index


Code Index:

NAME

Top

HTML::FormFu::ExtJS::Element::ComboBox

VERSION

Top

version 0.090

DESCRIPTION

Top

Creates an editable select box.

The default ExtJS setup is:

  "mode"           : "local",
  "editable"       : true,
  "displayField"   : "text",
  "valueField"     : "value",
  "autoWidth"      : false,
  "forceSelection" : true,
  "triggerAction"  : "all",
  "store"          : new Ext.data.SimpleStore( ... ),
  "xtype"          : "combo"

NAME

Top

HTML::FormFu::ExtJS::Element::ComboBox - An editable select box

SEE ALSO

Top

HTML::FormFu::Element::Select

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::ComboBox;
BEGIN {
  $HTML::FormFu::ExtJS::Element::ComboBox::VERSION = '0.090';
}

use base "HTML::FormFu::ExtJS::Element::Select";

use strict;
use warnings;
use utf8;

use JavaScript::Dumper;

sub render {
    my $class = shift;
    my $self  = shift;
    my $super = $class->SUPER::render($self);
    my $data;
    foreach my $option ( @{ $self->options } ) {
        push( @{$data}, [ $option->{value}, $option->{label} ] );
        if ( $option->{group} && ( my @groups = @{ $option->{group} } ) ) {
            foreach my $item (@groups) {
                push( @{$data}, [ $item->{value}, $item->{label} ] );
            }
        }
    }
    my $string = js_dumper( { fields => [ "value", "text" ], data => $data } );
    return {
        %{$super},

        editable => \1,
        store    => \( "new Ext.data.SimpleStore(" . $string . ")" ),
    };

}

1;


__END__