action_list.rst 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. The List View
  2. =============
  3. .. note::
  4. This document is a stub representing a new work in progress. If you're reading
  5. this you can help contribute, **no matter what your experience level with Sonata
  6. is**. Check out the `issues on Github`_ for more information about how to get involved.
  7. This document will cover the List view which you use to browse the objects in your
  8. system. It will cover configuration of the list itself and the filters you can use
  9. to control what's visible.
  10. Basic configuration
  11. -------------------
  12. To do:
  13. - global (yml) options that affect the list view
  14. - a note about Routes and how disabling them disables the related action
  15. - using configureListFields() to set which fields to display
  16. - setting the identifier, and the available options
  17. - options available when adding general fields, inc custom templates
  18. - targeting submodel fields using dot-separated notation
  19. - adding custom columns
  20. Customising the query used to generate the list
  21. -----------------------------------------------
  22. To do:
  23. - how to customize/optimize the list query
  24. Customising the sort order
  25. --------------------------
  26. Configure the default ordering in the list view
  27. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  28. Configuring the default ordering column can simply be achieved by overriding
  29. the ``datagridValues`` array property. All three keys ``_page``, ``_sort_order`` and
  30. ``_sort_by`` can be omitted.
  31. .. code-block:: php
  32. <?php
  33. use Sonata\AdminBundle\Admin\Admin;
  34. class PageAdmin extends Admin
  35. {
  36. // ...
  37. /**
  38. * Default Datagrid values
  39. *
  40. * @var array
  41. */
  42. protected $datagridValues = array(
  43. '_page' => 1, // display the first page (default = 1)
  44. '_sort_order' => 'DESC', // reverse order (default = 'ASC')
  45. '_sort_by' => 'updated' // name of the ordered field
  46. // (default = the model's id field, if any)
  47. // the '_sort_by' key can be of the form 'mySubModel.mySubSubModel.myField'.
  48. );
  49. // ...
  50. }
  51. To do:
  52. - how to sort by multiple fields (this might be a separate recipe?)
  53. Filters
  54. -------
  55. To do:
  56. - basic filter configuration and options
  57. - how to set default filter values
  58. - targeting submodel fields using dot-separated notation
  59. - advanced filter options
  60. .. _`issues on Github`: https://github.com/sonata-project/SonataAdminBundle/issues/1519