summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitattributes2
-rw-r--r--demos/quickstart/protected/pages/Controls/Samples/TDataGrid/Sample2.page25
-rw-r--r--demos/quickstart/protected/pages/Controls/Samples/TDataGrid/Sample2.php41
-rw-r--r--framework/Web/UI/WebControls/TDataGrid.php77
-rw-r--r--framework/Web/UI/WebControls/TDataList.php73
-rw-r--r--framework/Web/UI/WebControls/TFont.php18
-rw-r--r--framework/Web/UI/WebControls/TStyle.php42
7 files changed, 184 insertions, 94 deletions
diff --git a/.gitattributes b/.gitattributes
index 0072ea5e..fa25de82 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -118,6 +118,8 @@ demos/quickstart/protected/pages/Controls/Samples/TCustomValidator/Home.page -te
demos/quickstart/protected/pages/Controls/Samples/TCustomValidator/Home.php -text
demos/quickstart/protected/pages/Controls/Samples/TDataGrid/Sample1.page -text
demos/quickstart/protected/pages/Controls/Samples/TDataGrid/Sample1.php -text
+demos/quickstart/protected/pages/Controls/Samples/TDataGrid/Sample2.page -text
+demos/quickstart/protected/pages/Controls/Samples/TDataGrid/Sample2.php -text
demos/quickstart/protected/pages/Controls/Samples/TDataList/Sample1.page -text
demos/quickstart/protected/pages/Controls/Samples/TDataList/Sample1.php -text
demos/quickstart/protected/pages/Controls/Samples/TDataList/Sample2.page -text
diff --git a/demos/quickstart/protected/pages/Controls/Samples/TDataGrid/Sample2.page b/demos/quickstart/protected/pages/Controls/Samples/TDataGrid/Sample2.page
new file mode 100644
index 00000000..c810708d
--- /dev/null
+++ b/demos/quickstart/protected/pages/Controls/Samples/TDataGrid/Sample2.page
@@ -0,0 +1,25 @@
+<com:TContent ID="body">
+
+<h1>TDataGrid Sample 2</h1>
+<h2>Using Manually Specified Columns</h2>
+
+<com:TDataGrid
+ ID="DataGrid"
+ AutoGenerateColumns="false"
+ EnableViewState="false"
+ HeaderStyle.BackColor="silver"
+ ItemStyle.BackColor="lightblue"
+ ItemStyle.Font.Italic="true"
+ AlternatingItemStyle.BackColor="lightgreen">
+
+ <com:TBoundColumn
+ ItemStyle.BackColor="silver"
+ HeaderText="Name"
+ DataField="name"
+ />
+ <com:TCheckBoxColumn
+ HeaderText="Imported"
+ DataField="imported" />
+</com:TDataGrid>
+
+</com:TContent> \ No newline at end of file
diff --git a/demos/quickstart/protected/pages/Controls/Samples/TDataGrid/Sample2.php b/demos/quickstart/protected/pages/Controls/Samples/TDataGrid/Sample2.php
new file mode 100644
index 00000000..3d0bdf2d
--- /dev/null
+++ b/demos/quickstart/protected/pages/Controls/Samples/TDataGrid/Sample2.php
@@ -0,0 +1,41 @@
+<?php
+
+class Sample2 extends TPage
+{
+ protected function getData()
+ {
+ return array(
+ array('id'=>'ITN001','name'=>'Motherboard','quantity'=>1,'price'=>100.00,'imported'=>true),
+ array('id'=>'ITN002','name'=>'CPU','quantity'=>1,'price'=>150.00,'imported'=>true),
+ array('id'=>'ITN003','name'=>'Harddrive','quantity'=>2,'price'=>80.00,'imported'=>true),
+ array('id'=>'ITN004','name'=>'Sound card','quantity'=>1,'price'=>40.00,'imported'=>false),
+ array('id'=>'ITN005','name'=>'Video card','quantity'=>1,'price'=>150.00,'imported'=>true),
+ array('id'=>'ITN006','name'=>'Keyboard','quantity'=>1,'price'=>20.00,'imported'=>false),
+ array('id'=>'ITN007','name'=>'Monitor','quantity'=>2,'price'=>300.00,'imported'=>true),
+ array('id'=>'ITN008','name'=>'CDRW drive','quantity'=>1,'price'=>40.00,'imported'=>true),
+ array('id'=>'ITN009','name'=>'Cooling fan','quantity'=>2,'price'=>10.00,'imported'=>false),
+ array('id'=>'ITN010','name'=>'Video camera','quantity'=>20,'price'=>30.00,'imported'=>true),
+ array('id'=>'ITN011','name'=>'Card reader','quantity'=>10,'price'=>24.00,'imported'=>true),
+ array('id'=>'ITN012','name'=>'Floppy drive','quantity'=>50,'price'=>12.00,'imported'=>false),
+ array('id'=>'ITN013','name'=>'CD drive','quantity'=>25,'price'=>20.00,'imported'=>true),
+ array('id'=>'ITN014','name'=>'DVD drive','quantity'=>15,'price'=>80.00,'imported'=>true),
+ array('id'=>'ITN015','name'=>'Mouse pad','quantity'=>50,'price'=>5.00,'imported'=>false),
+ array('id'=>'ITN016','name'=>'Network cable','quantity'=>40,'price'=>8.00,'imported'=>true),
+ array('id'=>'ITN017','name'=>'Case','quantity'=>8,'price'=>65.00,'imported'=>false),
+ array('id'=>'ITN018','name'=>'Surge protector','quantity'=>45,'price'=>15.00,'imported'=>false),
+ array('id'=>'ITN019','name'=>'Speaker','quantity'=>35,'price'=>65.00,'imported'=>false),
+ );
+ }
+
+ public function onLoad($param)
+ {
+ parent::onLoad($param);
+ if(!$this->IsPostBack)
+ {
+ $this->DataGrid->DataSource=$this->Data;
+ $this->DataGrid->dataBind();
+ }
+ }
+}
+
+?> \ No newline at end of file
diff --git a/framework/Web/UI/WebControls/TDataGrid.php b/framework/Web/UI/WebControls/TDataGrid.php
index 81fe2ce1..f8dd0b17 100644
--- a/framework/Web/UI/WebControls/TDataGrid.php
+++ b/framework/Web/UI/WebControls/TDataGrid.php
@@ -442,11 +442,11 @@ class TDataGrid extends TBaseDataList
}
/**
- * @return boolean whether datagrid columns should be automatically generated Defaults to false.
+ * @return boolean whether datagrid columns should be automatically generated. Defaults to true.
*/
public function getAutoGenerateColumns()
{
- return $this->getViewState('AutoGenerateColumns',false);
+ return $this->getViewState('AutoGenerateColumns',true);
}
/**
@@ -454,7 +454,7 @@ class TDataGrid extends TBaseDataList
*/
public function setAutoGenerateColumns($value)
{
- $this->setViewState('AutoGenerateColumns',TPropertyValue::ensureBoolean($value),false);
+ $this->setViewState('AutoGenerateColumns',TPropertyValue::ensureBoolean($value),true);
}
/**
@@ -1157,33 +1157,22 @@ class TDataGrid extends TBaseDataList
*/
protected function applyItemStyles()
{
+ $itemStyle=$this->getViewState('ItemStyle',null);
+
+ $alternatingItemStyle=new TTableItemStyle($itemStyle);
+ if(($style=$this->getViewState('AlternatingItemStyle',null))!==null)
+ $alternatingItemStyle->mergeWith($style);
+
+ $selectedItemStyle=$this->getViewState('SelectedItemStyle',null);
+
+ $editItemStyle=new TTableItemStyle($selectedItemStyle);
+ if(($style=$this->getViewState('EditItemStyle',null))!==null)
+ $editItemStyle->copyFrom($style);
+
$headerStyle=$this->getViewState('HeaderStyle',null);
$footerStyle=$this->getViewState('FooterStyle',null);
$pagerStyle=$this->getViewState('PagerStyle',null);
$separatorStyle=$this->getViewState('SeparatorStyle',null);
- $itemStyle=$this->getViewState('ItemStyle',null);
- $alternatingItemStyle=$this->getViewState('AlternatingItemStyle',null);
- if($itemStyle!==null)
- {
- if($alternatingItemStyle===null)
- $alternatingItemStyle=$itemStyle;
- else
- $alternatingItemStyle->mergeWith($itemStyle);
- }
- $selectedItemStyle=$this->getViewState('SelectedItemStyle',null);
- if($alternatingItemStyle!==null)
- {
- if($selectedItemStyle===null)
- $selectedItemStyle=new TTableItemStyle;
- $selectedItemStyle->mergeWith($alternatingItemStyle);
- }
- $editItemStyle=$this->getViewState('EditItemStyle',null);
- if($selectedItemStyle!==null)
- {
- if($editItemStyle===null)
- $editItemStyle=new TTableItemStyle;
- $editItemStyle->mergeWith($selectedItemStyle);
- }
foreach($this->getControls() as $index=>$item)
{
@@ -1215,10 +1204,30 @@ class TDataGrid extends TBaseDataList
$item->getStyle()->mergeWith($alternatingItemStyle);
break;
case 'SelectedItem':
+ if($index % 2==1)
+ {
+ if($itemStyle)
+ $item->getStyle()->mergeWith($itemStyle);
+ }
+ else
+ {
+ if($alternatingItemStyle)
+ $item->getStyle()->mergeWith($alternatingItemStyle);
+ }
if($selectedItemStyle)
$item->getStyle()->mergeWith($selectedItemStyle);
break;
case 'EditItem':
+ if($index % 2==1)
+ {
+ if($itemStyle)
+ $item->getStyle()->mergeWith($itemStyle);
+ }
+ else
+ {
+ if($alternatingItemStyle)
+ $item->getStyle()->mergeWith($alternatingItemStyle);
+ }
if($editItemStyle)
$item->getStyle()->mergeWith($editItemStyle);
break;
@@ -1761,8 +1770,8 @@ class TDataGridPagerStyle extends TTableItemStyle
/**
* Merges with a style.
- * If a style field is not set in the current style but set in the new style
- * it will take the value from the new style.
+ * If a style field is set in the new style, the current style field
+ * will be overwritten.
* This method overrides the parent implementation by
* merging with additional TDataGridPagerStyle specific attributes.
* @param TStyle the new style
@@ -1772,17 +1781,17 @@ class TDataGridPagerStyle extends TTableItemStyle
parent::mergeWith($style);
if($style instanceof TDataGridPagerStyle)
{
- if($style->_visible!==null && $this->_visible===null)
+ if($style->_visible!==null)
$this->_visible=$style->_visible;
- if($style->_position!==null && $this->_position===null)
+ if($style->_position!==null)
$this->_position=$style->_position;
- if($style->_buttonCount!==null && $this->_buttonCount===null)
+ if($style->_buttonCount!==null)
$this->_buttonCount=$style->_buttonCount;
- if($style->_prevText!==null && $this->_prevText===null)
+ if($style->_prevText!==null)
$this->_prevText=$style->_prevText;
- if($style->_nextText!==null && $this->_nextText===null)
+ if($style->_nextText!==null)
$this->_nextText=$style->_nextText;
- if($style->_mode!==null && $this->_mode===null)
+ if($style->_mode!==null)
$this->_mode=$style->_mode;
}
}
diff --git a/framework/Web/UI/WebControls/TDataList.php b/framework/Web/UI/WebControls/TDataList.php
index d04acdaf..0bdeb4a4 100644
--- a/framework/Web/UI/WebControls/TDataList.php
+++ b/framework/Web/UI/WebControls/TDataList.php
@@ -902,63 +902,74 @@ class TDataList extends TBaseDataList implements INamingContainer, IRepeatInfoUs
*/
protected function applyItemStyles()
{
+ $itemStyle=$this->getViewState('ItemStyle',null);
+
+ $alternatingItemStyle=new TTableItemStyle($itemStyle);
+ if(($style=$this->getViewState('AlternatingItemStyle',null))!==null)
+ $alternatingItemStyle->mergeWith($style);
+
+ $selectedItemStyle=$this->getViewState('SelectedItemStyle',null);
+
+ $editItemStyle=new TTableItemStyle($selectedItemStyle);
+ if(($style=$this->getViewState('EditItemStyle',null))!==null)
+ $editItemStyle->copyFrom($style);
+
$headerStyle=$this->getViewState('HeaderStyle',null);
$footerStyle=$this->getViewState('FooterStyle',null);
+ $pagerStyle=$this->getViewState('PagerStyle',null);
$separatorStyle=$this->getViewState('SeparatorStyle',null);
- $itemStyle=$this->getViewState('ItemStyle',null);
- $alternatingItemStyle=$this->getViewState('AlternatingItemStyle',null);
- if($itemStyle!==null)
- {
- if($alternatingItemStyle===null)
- $alternatingItemStyle=new TTableItemStyle;
- $alternatingItemStyle->mergeWith($itemStyle);
- }
- $selectedItemStyle=$this->getViewState('SelectedItemStyle',null);
- if($alternatingItemStyle!==null)
- {
- if($selectedItemStyle===null)
- $selectedItemStyle=new TTableItemStyle;
- $selectedItemStyle->mergeWith($alternatingItemStyle);
- }
- $editItemStyle=$this->getViewState('EditItemStyle',null);
- if($selectedItemStyle!==null)
- {
- if($editItemStyle===null)
- $editItemStyle=new TTableItemStyle;
- $editItemStyle->mergeWith($selectedItemStyle);
- }
- foreach($this->getControls() as $control)
+ foreach($this->getControls() as $index=>$item)
{
- switch($control->getItemType())
+ switch($item->getItemType())
{
case 'Header':
if($headerStyle)
- $control->getStyle()->mergeWith($headerStyle);
+ $item->getStyle()->mergeWith($headerStyle);
break;
case 'Footer':
if($footerStyle)
- $control->getStyle()->mergeWith($footerStyle);
+ $item->getStyle()->mergeWith($footerStyle);
break;
case 'Separator':
if($separatorStyle)
- $control->getStyle()->mergeWith($separatorStyle);
+ $item->getStyle()->mergeWith($separatorStyle);
break;
case 'Item':
if($itemStyle)
- $control->getStyle()->mergeWith($itemStyle);
+ $item->getStyle()->mergeWith($itemStyle);
break;
case 'AlternatingItem':
if($alternatingItemStyle)
- $control->getStyle()->mergeWith($alternatingItemStyle);
+ $item->getStyle()->mergeWith($alternatingItemStyle);
break;
case 'SelectedItem':
+ if($index % 2==1)
+ {
+ if($itemStyle)
+ $item->getStyle()->mergeWith($itemStyle);
+ }
+ else
+ {
+ if($alternatingItemStyle)
+ $item->getStyle()->mergeWith($alternatingItemStyle);
+ }
if($selectedItemStyle)
- $control->getStyle()->mergeWith($selectedItemStyle);
+ $item->getStyle()->mergeWith($selectedItemStyle);
break;
case 'EditItem':
+ if($index % 2==1)
+ {
+ if($itemStyle)
+ $item->getStyle()->mergeWith($itemStyle);
+ }
+ else
+ {
+ if($alternatingItemStyle)
+ $item->getStyle()->mergeWith($alternatingItemStyle);
+ }
if($editItemStyle)
- $control->getStyle()->mergeWith($editItemStyle);
+ $item->getStyle()->mergeWith($editItemStyle);
break;
default:
break;
diff --git a/framework/Web/UI/WebControls/TFont.php b/framework/Web/UI/WebControls/TFont.php
index d958c0ee..51d864c3 100644
--- a/framework/Web/UI/WebControls/TFont.php
+++ b/framework/Web/UI/WebControls/TFont.php
@@ -209,27 +209,27 @@ class TFont extends TComponent
/**
* Merges the font with a new one.
- * If a style field is not set in the current style but set in the new style
- * it will take the value from the new style.
+ * If a font field is set in the new font, the current font field
+ * will be overwritten.
* @param TFont the new font
*/
public function mergeWith($font)
{
if($font===null || $font->_flags===0)
return;
- if(($font->_flags & self::IS_SET_BOLD) && !($this->_flags & self::IS_SET_BOLD))
+ if($font->_flags & self::IS_SET_BOLD)
$this->setBold($font->getBold());
- if(($font->_flags & self::IS_SET_ITALIC) && !($this->_flags & self::IS_SET_ITALIC))
+ if($font->_flags & self::IS_SET_ITALIC)
$this->setItalic($font->getItalic());
- if(($font->_flags & self::IS_SET_OVERLINE) && !($this->_flags & self::IS_SET_OVERLINE))
+ if($font->_flags & self::IS_SET_OVERLINE)
$this->setOverline($font->getOverline());
- if(($font->_flags & self::IS_SET_STRIKEOUT) && !($this->_flags & self::IS_SET_STRIKEOUT))
+ if($font->_flags & self::IS_SET_STRIKEOUT)
$this->setStrikeout($font->getStrikeout());
- if(($font->_flags & self::IS_SET_UNDERLINE) && !($this->_flags & self::IS_SET_UNDERLINE))
+ if($font->_flags & self::IS_SET_UNDERLINE)
$this->setUnderline($font->getUnderline());
- if(($font->_flags & self::IS_SET_SIZE) && !($this->_flags & self::IS_SET_SIZE))
+ if($font->_flags & self::IS_SET_SIZE)
$this->setSize($font->getSize());
- if(($font->_flags & self::IS_SET_NAME) && !($this->_flags & self::IS_SET_NAME))
+ if($font->_flags & self::IS_SET_NAME)
$this->setName($font->getName());
}
diff --git a/framework/Web/UI/WebControls/TStyle.php b/framework/Web/UI/WebControls/TStyle.php
index fa3bcb28..dac862a6 100644
--- a/framework/Web/UI/WebControls/TStyle.php
+++ b/framework/Web/UI/WebControls/TStyle.php
@@ -50,7 +50,8 @@ class TStyle extends TComponent
*/
public function __construct($style=null)
{
- $this->copyFrom($style);
+ if($style!==null)
+ $this->copyFrom($style);
}
/**
@@ -295,21 +296,20 @@ class TStyle extends TComponent
/**
* Merges with a style.
- * If a style field is not set in the current style but set in the new style
- * it will take the value from the new style.
+ * If a style field is set in the new style, the current style field
+ * will be overwritten.
* @param TStyle the new style
*/
public function mergeWith($style)
{
if($style!==null)
{
- //$this->_fields=array_merge($this->_fields,$style->_fields);
- $this->_fields=array_merge($style->_fields,$this->_fields);
- if($this->_class===null)
+ $this->_fields=array_merge($this->_fields,$style->_fields);
+ if($style->_class!==null)
$this->_class=$style->_class;
- if($this->_customStyle===null)
+ if($style->_customStyle!==null)
$this->_customStyle=$style->_customStyle;
- if($this->_font===null && $style->_font!==null)
+ if($style->_font!==null)
$this->getFont()->mergeWith($style->_font);
}
}
@@ -405,8 +405,9 @@ class TTableStyle extends TStyle
/**
* Merges with a style.
- * If a style field is not set in the current style but set in the new style
- * it will take the value from the new style.
+ * Merges with a style.
+ * If a style field is set in the new style, the current style field
+ * will be overwritten.
* This method overrides the parent implementation by
* merging with additional TTableStyle specific attributes.
* @param TStyle the new style
@@ -416,15 +417,15 @@ class TTableStyle extends TStyle
parent::mergeWith($style);
if($style instanceof TTableStyle)
{
- if($style->_backImageUrl!==null && $this->_backImageUrl===null)
+ if($style->_backImageUrl!==null)
$this->_backImageUrl=$style->_backImageUrl;
- if($style->_horizontalAlign!==null && $this->_horizontalAlign===null)
+ if($style->_horizontalAlign!==null)
$this->_horizontalAlign=$style->_horizontalAlign;
- if($style->_cellPadding!==null && $this->_cellPadding===null)
+ if($style->_cellPadding!==null)
$this->_cellPadding=$style->_cellPadding;
- if($style->_cellSpacing!==null && $this->_cellSpacing===null)
+ if($style->_cellSpacing!==null)
$this->_cellSpacing=$style->_cellSpacing;
- if($style->_gridLines!==null && $this->_gridLines===null)
+ if($style->_gridLines!==null)
$this->_gridLines=$style->_gridLines;
}
}
@@ -615,8 +616,9 @@ class TTableItemStyle extends TStyle
/**
* Merges with a style.
- * If a style field is not set in the current style but set in the new style
- * it will take the value from the new style.
+ * Merges with a style.
+ * If a style field is set in the new style, the current style field
+ * will be overwritten.
* This method overrides the parent implementation by
* merging with additional TTableItemStyle specific attributes.
* @param TStyle the new style
@@ -626,11 +628,11 @@ class TTableItemStyle extends TStyle
parent::mergeWith($style);
if($style instanceof TTableItemStyle)
{
- if($style->_verticalAlign!==null && $this->_verticalAlign===null)
+ if($style->_verticalAlign!==null)
$this->_verticalAlign=$style->_verticalAlign;
- if($style->_horizontalAlign!==null && $this->_horizontalAlign===null)
+ if($style->_horizontalAlign!==null)
$this->_horizontalAlign=$style->_horizontalAlign;
- if($style->_wrap!==null && $this->_wrap===null)
+ if($style->_wrap!==null)
$this->_wrap=$style->_wrap;
}
}