Author: Leon.van.der.Ree
Date: 2010-04-17 21:57:03 +0200 (Sat, 17 Apr 2010)
New Revision: 29187
Added:
plugins/sfGridPlugin/trunk/lib/action/
plugins/sfGridPlugin/trunk/lib/action/sfGridJavaScriptActions.php
Modified:
plugins/sfGridPlugin/trunk/lib/grid/sfContextGridJavaScript.class.php
plugins/sfGridPlugin/trunk/lib/grid/sfGrid.class.php
Log:
added javascript action, fixed bug for json not sorting
Added: plugins/sfGridPlugin/trunk/lib/action/sfGridJavaScriptActions.php
===================================================================
--- plugins/sfGridPlugin/trunk/lib/action/sfGridJavaScriptActions.php
(rev 0)
+++ plugins/sfGridPlugin/trunk/lib/action/sfGridJavaScriptActions.php
2010-04-17 19:57:03 UTC (rev 29187)
@@ -0,0 +1,43 @@
+<?php
+
+/**
+ * sfGridJavaScript Actions.
+ *
+ * @package symfony
+ * @subpackage sfGridPlugin
+ * @author Leon van der Ree
+ * @version SVN: $Id: $
+ */
+class sfGridJavaScriptActions extends sfActions
+{
+
+ /**
+ * @see sfActions
+ */
+ public function execute($request)
+ {
+ $this->grid = $this->getRoute()->getObject(); // TODO: getGrid()
+
+ $response = $this->getResponse();
+ if ($request->getRequestFormat() == 'json')
+ {
+ sfConfig::set('sf_web_debug', false);
+ $response->setContentType('application/json');
+
+ return $this->renderText($this->grid->renderData());
+ }
+ elseif ($request->getRequestFormat() == 'js')
+ {
+ sfConfig::set('sf_web_debug', false);
+ $response->setContentType('text/javascript');
+ return $this->renderText($this->grid->renderJavaScript());
+ }
+
+ // when html version requested:
+
+ // and include javascript as well of course
+
$response->addJavascript($this->getController()->genUrl($this->grid->getUri()."?sf_format=js"),
'last');
+
+ return parent::execute($request);
+ }
+}
Modified: plugins/sfGridPlugin/trunk/lib/grid/sfContextGridJavaScript.class.php
===================================================================
--- plugins/sfGridPlugin/trunk/lib/grid/sfContextGridJavaScript.class.php
2010-04-17 19:54:40 UTC (rev 29186)
+++ plugins/sfGridPlugin/trunk/lib/grid/sfContextGridJavaScript.class.php
2010-04-17 19:57:03 UTC (rev 29187)
@@ -74,6 +74,7 @@
{
$this->setSort($this->defaultSortColumn, $this->defaultSortOrder);
}
+ $this->doSort();
// update offset lazy, now is a good time to request last page and check
if we don't requested a higher pager
$this->getDataSource()->setOffset($this->getPager()->getFirstIndex());
Modified: plugins/sfGridPlugin/trunk/lib/grid/sfGrid.class.php
===================================================================
--- plugins/sfGridPlugin/trunk/lib/grid/sfGrid.class.php 2010-04-17
19:54:40 UTC (rev 29186)
+++ plugins/sfGridPlugin/trunk/lib/grid/sfGrid.class.php 2010-04-17
19:57:03 UTC (rev 29187)
@@ -434,7 +434,7 @@
{
throw new LogicException('Unable to sort on column: "'.$column.'"');
}
-
+
$this->sortColumn = $column;
$this->sortOrder = ($order == sfGrid::ASC ? sfDataSourceInterface::ASC :
sfDataSourceInterface::DESC);
}
--
You received this message because you are subscribed to the Google Groups
"symfony SVN" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/symfony-svn?hl=en.