summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxue <>2006-02-03 22:17:33 +0000
committerxue <>2006-02-03 22:17:33 +0000
commit979430b5bf60e5857846ecb561404a89c02cefcd (patch)
treecc8d51f086da6b36542e5ee9622329590fc72733
parentbaac41fc1e52c2902feabf778915195042b196b0 (diff)
Completed datagrid tutorial part one and added a new datagrid sample.
-rw-r--r--.gitattributes6
-rw-r--r--demos/quickstart/images/star1.gifbin0 -> 385 bytes
-rw-r--r--demos/quickstart/images/star2.gifbin0 -> 382 bytes
-rw-r--r--demos/quickstart/images/star3.gifbin0 -> 388 bytes
-rw-r--r--demos/quickstart/images/star4.gifbin0 -> 397 bytes
-rw-r--r--demos/quickstart/images/star5.gifbin0 -> 394 bytes
-rw-r--r--demos/quickstart/protected/pages/Controls/DataGrid.page9
-rw-r--r--demos/quickstart/protected/pages/Controls/DataGrid1.page18
-rw-r--r--demos/quickstart/protected/pages/Controls/Overview.page2
-rw-r--r--demos/quickstart/protected/pages/Controls/Samples/TDataGrid/Sample2.page40
-rw-r--r--demos/quickstart/protected/pages/Controls/Samples/TDataGrid/Sample2.php75
-rw-r--r--framework/Web/UI/WebControls/TBoundColumn.php12
-rw-r--r--framework/Web/UI/WebControls/TDataGridColumn.php12
-rw-r--r--framework/Web/UI/WebControls/TFont.php20
-rw-r--r--framework/Web/UI/WebControls/TStyle.php2
-rw-r--r--framework/Web/UI/WebControls/TTemplateColumn.php2
16 files changed, 134 insertions, 64 deletions
diff --git a/.gitattributes b/.gitattributes
index fa25de82..e3859b99 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -38,6 +38,11 @@ demos/personal/protected/application.xml -text
demos/personal/themes/BlueTheme/buttons.skin -text
demos/personal/themes/BlueTheme/icon_profile.gif -text
demos/personal/themes/BlueTheme/labels.skin -text
+demos/quickstart/images/star1.gif -text
+demos/quickstart/images/star2.gif -text
+demos/quickstart/images/star3.gif -text
+demos/quickstart/images/star4.gif -text
+demos/quickstart/images/star5.gif -text
demos/quickstart/index.php -text
demos/quickstart/index2.php -text
demos/quickstart/protected/.htaccess -text
@@ -96,7 +101,6 @@ demos/quickstart/protected/pages/Configurations/Templates1.page -text
demos/quickstart/protected/pages/Configurations/Templates2.page -text
demos/quickstart/protected/pages/Configurations/Templates3.page -text
demos/quickstart/protected/pages/Construction.page -text
-demos/quickstart/protected/pages/Controls/DataGrid.page -text
demos/quickstart/protected/pages/Controls/DataGrid1.page -text
demos/quickstart/protected/pages/Controls/DataGrid2.page -text
demos/quickstart/protected/pages/Controls/DataList.page -text
diff --git a/demos/quickstart/images/star1.gif b/demos/quickstart/images/star1.gif
new file mode 100644
index 00000000..f47a0ae4
--- /dev/null
+++ b/demos/quickstart/images/star1.gif
Binary files differ
diff --git a/demos/quickstart/images/star2.gif b/demos/quickstart/images/star2.gif
new file mode 100644
index 00000000..b400fd7c
--- /dev/null
+++ b/demos/quickstart/images/star2.gif
Binary files differ
diff --git a/demos/quickstart/images/star3.gif b/demos/quickstart/images/star3.gif
new file mode 100644
index 00000000..74582c6d
--- /dev/null
+++ b/demos/quickstart/images/star3.gif
Binary files differ
diff --git a/demos/quickstart/images/star4.gif b/demos/quickstart/images/star4.gif
new file mode 100644
index 00000000..f05c24d5
--- /dev/null
+++ b/demos/quickstart/images/star4.gif
Binary files differ
diff --git a/demos/quickstart/images/star5.gif b/demos/quickstart/images/star5.gif
new file mode 100644
index 00000000..f6a4bb71
--- /dev/null
+++ b/demos/quickstart/images/star5.gif
Binary files differ
diff --git a/demos/quickstart/protected/pages/Controls/DataGrid.page b/demos/quickstart/protected/pages/Controls/DataGrid.page
deleted file mode 100644
index 9170fe45..00000000
--- a/demos/quickstart/protected/pages/Controls/DataGrid.page
+++ /dev/null
@@ -1,9 +0,0 @@
-<com:TContent ID="body" >
-
-<h1>TDataGrid</h1>
-<p>
-TBC
-</p>
-<com:RunBar PagePath="Controls.Samples.TDataGrid.Sample1" />
-
-</com:TContent> \ No newline at end of file
diff --git a/demos/quickstart/protected/pages/Controls/DataGrid1.page b/demos/quickstart/protected/pages/Controls/DataGrid1.page
index 27e5a777..b7d6fe8f 100644
--- a/demos/quickstart/protected/pages/Controls/DataGrid1.page
+++ b/demos/quickstart/protected/pages/Controls/DataGrid1.page
@@ -21,6 +21,7 @@ PRADO provides five types of columns:
</p>
<ul>
<li><tt>TBoundColumn</tt> associates cells with a specific field of data and displays the cells according to their modes.</li>
+ <li><tt>TCheckBoxColumn</tt> associates cells with a specific field of data and displays in each cell a checkbox whose check state is determined by the data field value.</li>
<li><tt>THyperLinkColumn</tt> displays in the cells a hyperlink whose caption and URL can be either statically specified or bound to some fields of data.</li>
<li><tt>TEditCommandColumn</tt> displays in the cells edit/update/cancel command buttons according to the state of the item that a cell resides in.</li>
<li><tt>TButtonColumn</tt> displays in the cells a command button.
@@ -63,7 +64,7 @@ TDataGrid provides several events to facilitate manipulation of its items,
TDataGrid by default will create a list of columns based on the structure of the bound data. TDataGrid will read the first row of the data, extract the field names of the row, and construct a column for each field. Each column is of type <tt>TBoundColumn</tt>.
</p>
<p>
-The following example displays a list of computer product information using a TDataGrid. Columns are automatically generated. To populate datagrid items with the data, <tt>dataBind()</tt> is invoked for the datagrid in the <tt>onLoad</tt> method of the page,
+The following example displays a list of computer product information using a TDataGrid. Columns are automatically generated. Pay attention to how item styles are specified and inherited. The data are populated into the datagrid using the follow code, which is common among most datagrid applications,
</p>
<com:TTextHighlighter Language="php" CssClass="source">
public function onLoad($param) {
@@ -78,7 +79,7 @@ public function onLoad($param) {
<h3>Manually Specified Columns</h3>
<p>
-Using automatically generated columns gives a quick way of browsing tabular data. In real applications, however, automatically generated columns are often not enough because developers have no way configuring their properties. Manually specified columns are thus more desirable.
+Using automatically generated columns gives a quick way of browsing tabular data. In real applications, however, automatically generated columns are often not sufficient because developers have no way customizing their appearance. Manually specified columns are thus more desirable.
</p>
<p>
To manually specify columns, set <tt>AutoGenerateColumns</tt> to false, and specify the columns in a template like the following,
@@ -92,8 +93,19 @@ To manually specify columns, set <tt>AutoGenerateColumns</tt> to false, and spec
&lt;/com:TDataGrid&gt;
</com:TTextHighlighter>
<p>
-Note, if <tt>AutoGenerateColumns</tt> is true and there are manually specified columns, the automatically generated columns will be appended to the manually specified columns. Also note, the datagrid's <tt>Columns</tt> property only contains manually specified columns.
+Note, if <tt>AutoGenerateColumns</tt> is true and there are manually specified columns, the automatically generated columns will be appended to the manually specified columns. Also note, the datagrid's <tt>Columns</tt> property contains only manually specified columns and no automatically generated ones.
</p>
+<p>
+The following example uses manually specified columns to show a list of book information,
+</p>
+<ul>
+ <li>Book title - displayed a hyperlink pointing to the corresponding amazon.com book page. <tt>THyperLinkColumn</tt> is used.</li>
+ <li>Publisher - displayed as a piece of text using <tt>TBoundColumn</tt>.</li>
+ <li>Price - displayed as a piece of text using <tt>TBoundColumn</tt> with output formatting string and customized styles.</li>
+ <li>In-stock or not - displayed as a checkbox using <tt>TCheckBoxColumn</tt>.</li>
+ <li>Rating - displayed as an image using <tt>TTemplateColumn</tt> which allows maximum freedom in specifiying cell contents.</li>
+</ul>
+<p>Pay attention to how item (row) styles and column styles cooperate together to affect the appearance of the cells in the datagrid.</p>
<com:RunBar PagePath="Controls.Samples.TDataGrid.Sample2" />
</com:TContent> \ No newline at end of file
diff --git a/demos/quickstart/protected/pages/Controls/Overview.page b/demos/quickstart/protected/pages/Controls/Overview.page
index 03b4a2a2..ec3ac5be 100644
--- a/demos/quickstart/protected/pages/Controls/Overview.page
+++ b/demos/quickstart/protected/pages/Controls/Overview.page
@@ -4,6 +4,6 @@
Control are components defined in addition with user interface. Control classes constitute a major part of the PRADO framework. Nearly every generic HTML element can find its representation in terms of a PRADO control. Mastering these controls becomes extremely important for developers to compose effectively and efficiently applications using PRADO.
</p>
<p>
-To be continued...
+TBW: Control ID, Parent, NamingContainer, ViewState, ControlState, TWebControl, DataBound Control, ActiveControls
</p>
</com:TContent> \ No newline at end of file
diff --git a/demos/quickstart/protected/pages/Controls/Samples/TDataGrid/Sample2.page b/demos/quickstart/protected/pages/Controls/Samples/TDataGrid/Sample2.page
index c810708d..1a38c90d 100644
--- a/demos/quickstart/protected/pages/Controls/Samples/TDataGrid/Sample2.page
+++ b/demos/quickstart/protected/pages/Controls/Samples/TDataGrid/Sample2.page
@@ -4,22 +4,46 @@
<h2>Using Manually Specified Columns</h2>
<com:TDataGrid
+ Width="700px"
ID="DataGrid"
AutoGenerateColumns="false"
EnableViewState="false"
- HeaderStyle.BackColor="silver"
- ItemStyle.BackColor="lightblue"
+ HeaderStyle.BackColor="black"
+ HeaderStyle.ForeColor="white"
+ ItemStyle.BackColor="#BFCFFF"
ItemStyle.Font.Italic="true"
- AlternatingItemStyle.BackColor="lightgreen">
+ AlternatingItemStyle.BackColor="#E6ECFF">
+ <com:THyperLinkColumn
+ HeaderText="Book Title"
+ DataTextField="title"
+ DataNavigateUrlField="ISBN"
+ DataNavigateUrlFormatString="http://www.amazon.com/gp/product/%s"
+ Target="_blank"
+ />
+ <com:TBoundColumn
+ HeaderText="Publisher"
+ DataField="publisher"
+ />
<com:TBoundColumn
- ItemStyle.BackColor="silver"
- HeaderText="Name"
- DataField="name"
+ ItemStyle.HorizontalAlign="Right"
+ ItemStyle.Wrap="false"
+ ItemStyle.Font.Italic="false"
+ ItemStyle.ForeColor="green"
+ HeaderText="Price"
+ DataField="price"
+ DataFormatString="$%.2f"
/>
<com:TCheckBoxColumn
- HeaderText="Imported"
- DataField="imported" />
+ HeaderText="In-stock"
+ DataField="instock"
+ />
+ <com:TTemplateColumn>
+ <prop:HeaderTemplate>Rating</prop:HeaderTemplate>
+ <prop:ItemTemplate>
+ <img src="images/star<%#$this->NamingContainer->DataItem['rating']%>.gif" alt="" />
+ </prop:ItemTemplate>
+ </com:TTemplateColumn>
</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
index 3d0bdf2d..16a32c28 100644
--- a/demos/quickstart/protected/pages/Controls/Samples/TDataGrid/Sample2.php
+++ b/demos/quickstart/protected/pages/Controls/Samples/TDataGrid/Sample2.php
@@ -5,25 +5,62 @@ 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),
+ array(
+ 'ISBN'=>'0596007124',
+ 'title'=>'Head First Design Patterns',
+ 'publisher'=>'O\'Reilly Media, Inc.',
+ 'price'=>29.67,
+ 'instock'=>true,
+ 'rating'=>4,
+ ),
+ array(
+ 'ISBN'=>'0201633612',
+ 'title'=>'Design Patterns: Elements of Reusable Object-Oriented Software',
+ 'publisher'=>'Addison-Wesley Professional',
+ 'price'=>47.04,
+ 'instock'=>true,
+ 'rating'=>5,
+ ),
+ array(
+ 'ISBN'=>'0321247140',
+ 'title'=>'Design Patterns Explained : A New Perspective on Object-Oriented Design',
+ 'publisher'=>'Addison-Wesley Professional',
+ 'price'=>37.49,
+ 'instock'=>true,
+ 'rating'=>4,
+ ),
+ array(
+ 'ISBN'=>'0201485672',
+ 'title'=>'Refactoring: Improving the Design of Existing Code',
+ 'publisher'=>'Addison-Wesley Professional',
+ 'price'=>47.14,
+ 'instock'=>true,
+ 'rating'=>3,
+ ),
+ array(
+ 'ISBN'=>'0321213351',
+ 'title'=>'Refactoring to Patterns',
+ 'publisher'=>'Addison-Wesley Professional',
+ 'price'=>38.49,
+ 'instock'=>true,
+ 'rating'=>2,
+ ),
+ array(
+ 'ISBN'=>'0735619670',
+ 'title'=>'Code Complete',
+ 'publisher'=>'Microsoft Press',
+ 'price'=>32.99,
+ 'instock'=>false,
+ 'rating'=>4,
+ ),
+ array(
+ 'ISBN'=>'0321278658 ',
+ 'title'=>'Extreme Programming Explained : Embrace Change',
+ 'publisher'=>'Addison-Wesley Professional',
+ 'price'=>34.99,
+ 'instock'=>true,
+ 'rating'=>3,
+ ),
);
}
diff --git a/framework/Web/UI/WebControls/TBoundColumn.php b/framework/Web/UI/WebControls/TBoundColumn.php
index c30d3ff6..6ad578d7 100644
--- a/framework/Web/UI/WebControls/TBoundColumn.php
+++ b/framework/Web/UI/WebControls/TBoundColumn.php
@@ -131,18 +131,6 @@ class TBoundColumn extends TDataGridColumn
if(($sender instanceof TTableCell) || ($sender instanceof TTextBox))
$sender->setText($value);
}
-
- /**
- * Formats the text value according to format string.
- * This method is invoked when setting the text to a cell.
- * This method can be overriden.
- * @param mixed the data associated with the cell
- * @return string the formatted result
- */
- protected function formatDataValue($formatString,$value)
- {
- return $formatString===''?TPropertyValue::ensureString($value):sprintf($formatString,$value);
- }
}
?> \ No newline at end of file
diff --git a/framework/Web/UI/WebControls/TDataGridColumn.php b/framework/Web/UI/WebControls/TDataGridColumn.php
index a5e939ef..41d11946 100644
--- a/framework/Web/UI/WebControls/TDataGridColumn.php
+++ b/framework/Web/UI/WebControls/TDataGridColumn.php
@@ -308,6 +308,18 @@ abstract class TDataGridColumn extends TComponent
break;
}
}
+
+ /**
+ * Formats the text value according to format string.
+ * This method is invoked when setting the text to a cell.
+ * This method can be overriden.
+ * @param mixed the data associated with the cell
+ * @return string the formatted result
+ */
+ protected function formatDataValue($formatString,$value)
+ {
+ return $formatString===''?TPropertyValue::ensureString($value):sprintf($formatString,$value);
+ }
}
?> \ No newline at end of file
diff --git a/framework/Web/UI/WebControls/TFont.php b/framework/Web/UI/WebControls/TFont.php
index 51d864c3..2f95e2bd 100644
--- a/framework/Web/UI/WebControls/TFont.php
+++ b/framework/Web/UI/WebControls/TFont.php
@@ -56,7 +56,7 @@ class TFont extends TComponent
private $_size='';
/**
- * @return boolean whether the font is in bold face
+ * @return boolean whether the font is in bold face. Defaults to false.
*/
public function getBold()
{
@@ -69,14 +69,14 @@ class TFont extends TComponent
public function setBold($value)
{
$this->_flags |= self::IS_SET_BOLD;
- if($value)
+ if(TPropertyValue::ensureBoolean($value))
$this->_flags |= self::IS_BOLD;
else
$this->_flags &= ~self::IS_BOLD;
}
/**
- * @return boolean whether the font is in italic face
+ * @return boolean whether the font is in italic face. Defaults to false.
*/
public function getItalic()
{
@@ -89,14 +89,14 @@ class TFont extends TComponent
public function setItalic($value)
{
$this->_flags |= self::IS_SET_ITALIC;
- if($value)
+ if(TPropertyValue::ensureBoolean($value))
$this->_flags |= self::IS_ITALIC;
else
$this->_flags &= ~self::IS_ITALIC;
}
/**
- * @return boolean whether the font is overlined
+ * @return boolean whether the font is overlined. Defaults to false.
*/
public function getOverline()
{
@@ -109,7 +109,7 @@ class TFont extends TComponent
public function setOverline($value)
{
$this->_flags |= self::IS_SET_OVERLINE;
- if($value)
+ if(TPropertyValue::ensureBoolean($value))
$this->_flags |= self::IS_OVERLINE;
else
$this->_flags &= ~self::IS_OVERLINE;
@@ -133,7 +133,7 @@ class TFont extends TComponent
}
/**
- * @return boolean whether the font is strikeout
+ * @return boolean whether the font is strikeout. Defaults to false.
*/
public function getStrikeout()
{
@@ -146,14 +146,14 @@ class TFont extends TComponent
public function setStrikeout($value)
{
$this->_flags |= self::IS_SET_STRIKEOUT;
- if($value)
+ if(TPropertyValue::ensureBoolean($value))
$this->_flags |= self::IS_STRIKEOUT;
else
$this->_flags &= ~self::IS_STRIKEOUT;
}
/**
- * @return boolean whether the font is underlined
+ * @return boolean whether the font is underlined. Defaults to false.
*/
public function getUnderline()
{
@@ -166,7 +166,7 @@ class TFont extends TComponent
public function setUnderline($value)
{
$this->_flags |= self::IS_SET_UNDERLINE;
- if($value)
+ if(TPropertyValue::ensureBoolean($value))
$this->_flags |= self::IS_UNDERLINE;
else
$this->_flags &= ~self::IS_UNDERLINE;
diff --git a/framework/Web/UI/WebControls/TStyle.php b/framework/Web/UI/WebControls/TStyle.php
index dac862a6..ab7e8568 100644
--- a/framework/Web/UI/WebControls/TStyle.php
+++ b/framework/Web/UI/WebControls/TStyle.php
@@ -645,7 +645,7 @@ class TTableItemStyle extends TStyle
public function addAttributesToRender($writer)
{
if(!$this->getWrap())
- $writer->addStyleAttribute('nowrap','nowrap');
+ $writer->addStyleAttribute('white-space','nowrap');
if(($horizontalAlign=$this->getHorizontalAlign())!=='NotSet')
$writer->addAttribute('align',strtolower($horizontalAlign));
diff --git a/framework/Web/UI/WebControls/TTemplateColumn.php b/framework/Web/UI/WebControls/TTemplateColumn.php
index 9c386543..8d852d68 100644
--- a/framework/Web/UI/WebControls/TTemplateColumn.php
+++ b/framework/Web/UI/WebControls/TTemplateColumn.php
@@ -155,6 +155,8 @@ class TTemplateColumn extends TDataGridColumn
$cell->getControls()->clear();
$template->instantiateIn($cell);
}
+ else
+ $cell->setText('&nbsp;');
}
}