You are viewing a plain text version of this content. The canonical link for it is here.
Posted to embperl-cvs@perl.apache.org by ri...@apache.org on 2012/08/18 15:36:39 UTC

svn commit: r1374579 - /perl/embperl/trunk/Embperl/Form/Control/grid.pm

Author: richter
Date: Sat Aug 18 13:36:39 2012
New Revision: 1374579

URL: http://svn.apache.org/viewvc?rev=1374579&view=rev
Log:
Allow grid in grid

Modified:
    perl/embperl/trunk/Embperl/Form/Control/grid.pm

Modified: perl/embperl/trunk/Embperl/Form/Control/grid.pm
URL: http://svn.apache.org/viewvc/perl/embperl/trunk/Embperl/Form/Control/grid.pm?rev=1374579&r1=1374578&r2=1374579&view=diff
==============================================================================
--- perl/embperl/trunk/Embperl/Form/Control/grid.pm (original)
+++ perl/embperl/trunk/Embperl/Form/Control/grid.pm Sat Aug 18 13:36:39 2012
@@ -22,7 +22,7 @@ use base 'Embperl::Form::ControlMultValu
 use vars qw{%fdat $epreq} ;
 
 use Embperl::Inline ;
-use Storable ;
+use Data::Clone ;
 
 # ---------------------------------------------------------------------------
 #
@@ -54,15 +54,15 @@ sub init
     my ($self) = @_ ;
 
     $self -> {header_bottom} = 10 if (!exists ($self -> {header_bottom})) ;
-    $self -> {width} = 1 ;
+    $self -> {width} = 1 if (!$self -> {width}) ;
     
     my $flat   = $self -> {flatopt} ;
     my @flat   = split /\s*;\s*/, $flat ;
-    my $fields = $self -> {fields} ;
+    # make sure we do not change another instance of this grid
+    my $fields = $self -> {fields} = clone ($self -> {fields})  ;
     if (@flat)
         {
-        my $dfields =  Storable::dclone ($fields)  ;
-        foreach (@$dfields)
+        foreach (@$fields)
             {
             my $name = $_ -> {name} ;
             for (my $i = 0 ; $i < @flat; $i+=3)
@@ -70,8 +70,6 @@ sub init
                 $_ -> {$flat[$i+1]} = $flat[$i+2] if ($name eq $flat[$i]);        
                 }
             }
-        $fields = $dfields ;
-        $self -> {fields} = $fields ;    
         }
     my $form = $self -> form ;
     my $options = $form -> {options} ;
@@ -404,7 +402,7 @@ $]
          <tr class="cGridHeader">
          [$ foreach my $field (@$fields) $]
 			[* next if ($field -> is_hidden ) ; *]
-            <td class="cGridHeader" [$if($width = $field->{width})$]width="[+$width+]"[$endif$] _colattr="[+ $field->{name} +]">[+ $self -> form -> convert_label ($self, $field->{name}, $field->{text}) +]</td>
+            <td class="cGridHeader" style="[$if($width = $field->{width})$]width: [+$width+];[$endif$] [$if($width = $field->{min_width})$]min-width: [+$width+];[$endif$]" _colattr="[+ $field->{name} +]">[+ $self -> form -> convert_label ($self, $field->{name}, $field->{text}) +]</td>
          [$ endforeach $]
          </tr>
          </thead>
@@ -464,7 +462,7 @@ $]
                 $j++ ;
             -][$else$]
             [- $ro = $gridro || $field -> is_readonly () ; -]
-            <td class="[+ $ro?'cGridCellReadonly':'cGridCell' +]" [$if $field->{width}$]style="width: [+ $field->{width} +]"[$endif$]>[$if $n++ == 0$]<input type="hidden" name="[+ "__${name}_#row#_$i" +]" value="[+ $i +]">[$endif$][-
+            <td class="[+ $ro?'cGridCellReadonly':'cGridCell' +]" style="[$if($width = $field->{width})$]width: [+$width+];[$endif$]">[$if $n++ == 0$]<input type="hidden" name="[+ "__${name}_#row#_$i" +]" value="[+ $i +]">[$endif$][-
                 local $field -> {name}  = "__${name}_${j}_$i" ;
                 local $field -> {state} = $self -> {state} ;
                 if ($ro)



---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-cvs-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-cvs-help@perl.apache.org