瀏覽代碼

Add documentation for default paging and ordering configuration.

Romain Geissler 13 年之前
父節點
當前提交
19685d7401
共有 1 個文件被更改,包括 31 次插入1 次删除
  1. 31 1
      Resources/doc/reference/advance.rst

+ 31 - 1
Resources/doc/reference/advance.rst

@@ -86,4 +86,34 @@ application's config file:
 Admin Extension
 ---------------
 
-S
+Configure the default page and ordering in the list view
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Configuring the default page and ordering column can simply be achieved by overriding
+the ``datagridValues`` array property. All three keys ``_page``, ``_sort_order`` and
+``_sort_by`` can be omitted.
+
+.. code-block:: php
+
+    <?php
+
+    use Sonata\AdminBundle\Admin\Admin;
+
+    class PageAdmin extends Admin
+    {
+        // ...
+
+        /**
+         * Default Datagrid values
+         *
+         * @var array
+         */
+        protected $datagridValues = array(
+            '_page' => 1, // Display the first page (default = 1)
+            '_sort_order' => 'DESC', // Descendant ordering (default = 'ASC')
+            '_sort_by' => 'updated' // name of the ordered field (default = the model id field, if any)
+            // the '_sort_by' key can be of the form 'mySubModel.mySubSubModel.myField'.
+        );
+
+        // ...
+    }