From a6be5564823be40670e0cad8dc758557dbd37549 Mon Sep 17 00:00:00 2001
From: wei <>
Date: Sat, 24 Jun 2006 05:46:22 +0000
Subject: Update active controls.
---
.../UI/ActiveControls/TCallbackClientScript.php | 37 ++++++++++++++++++----
1 file changed, 30 insertions(+), 7 deletions(-)
(limited to 'framework/Web/UI/ActiveControls/TCallbackClientScript.php')
diff --git a/framework/Web/UI/ActiveControls/TCallbackClientScript.php b/framework/Web/UI/ActiveControls/TCallbackClientScript.php
index d83bf90a..0e1dff5c 100644
--- a/framework/Web/UI/ActiveControls/TCallbackClientScript.php
+++ b/framework/Web/UI/ActiveControls/TCallbackClientScript.php
@@ -53,7 +53,7 @@ class TCallbackClientScript extends TApplicationComponent
*/
public function getClientFunctionsToExecute()
{
- return $this->_actions;
+ return $this->_actions->toArray();
}
/**
@@ -89,18 +89,41 @@ class TCallbackClientScript extends TApplicationComponent
* or radio button list.
* The second parameter determines the selection method. Valid methods are
* - Value, select or check by value
- * - Index, select or check by list index (zero based index)
- * - All, selects or checks all in the list
+ * - Values, select or check by a list of values
+ * - Index, select or check by index (zero based index)
+ * - Indices, select or check by a list of index (zero based index)
* - Clear, clears or selections or checks in the list
- * - Invert, inverts the current selection or checks.
+ * - All, select all
+ * - Invert, invert the selection.
* @param TControl|string list control
* @param string selection method
* @param string|int the value or index to select/check.
+ * @param string selection control type, either 'check' or 'select'
*/
- public function select($listControl, $method="Value", $valueOrIndex=null)
+ public function select($control, $method='Value', $value=null, $type=null)
{
- $this->callClientFunction('Prado.Element.select', array($listControl, $method, $valueOrIndex));
+ $method = TPropertyValue::ensureEnum($method,
+ 'Value', 'Index', 'Clear', 'Indices', 'Values', 'All', 'Invert');
+ $type = is_null($type) ? $this->getSelectionControlType($control) : $type;
+ $total = $this->getSelectionControlIsListType($control) ? $control->getItemCount() : 1;
+ $this->callClientFunction('Prado.Element.select',
+ array($control, $type.$method, $value, $total));
}
+
+ private function getSelectionControlType($control)
+ {
+ if(is_string($control)) return 'check';
+ if($control instanceof TCheckBoxList)
+ return 'check';
+ if($control instanceof TCheckBox)
+ return 'check';
+ return 'select';
+ }
+
+ private function getSelectionControlIsListType($control)
+ {
+ return $control instanceof TListControl;
+ }
/**
* Client script to click on an element. This client-side function
@@ -138,7 +161,7 @@ class TCallbackClientScript extends TApplicationComponent
* @param TControl|string control element or element id
* @param TCollection a list of new options
*/
- public function setOptions($control, $items)
+ public function setListItems($control, $items)
{
$options = array();
foreach($items as $item)
--
cgit v1.2.3