README.rst 1.8 KB
Newer Older
Alain Leufroy's avatar
Alain Leufroy committed
1
Summary
2
3
=======

Alain Leufroy's avatar
Alain Leufroy committed
4
Table view rendered using the SlickGrid_ javascript library.
5
6
7

SlickGrid is an advanced JavaScript grid/spreadsheet component.

Alain Leufroy's avatar
Alain Leufroy committed
8
This view accepts any non-empty rset. It uses introspection on the
9
10
11
12
13
14
15
16
result set to compute column names and the proper way to display the
cells.

It is highly configuration and accepts the same wealth of option than
cubicweb.web.view.tableview.RsetTableView.

.. _SlickGrid: https://github.com/mleibman/SlickGrid

Alain Leufroy's avatar
Alain Leufroy committed
17
18
Example
=======
19
20
21
22
23
24

To try it at the speed of light
--------------------------------

Once your instance is running you can go to::

Alain Leufroy's avatar
Alain Leufroy committed
25
  http://localhost:8080/view?rql=Any L, X WHERE X is CWUser, X login L&vid=slickgrid
26
27
28
29
30
31

That's all. The rendered table uses the 'slickgrid' view.

Calling the slidgrid from your views
------------------------------------

Alain Leufroy's avatar
Alain Leufroy committed
32
The simplest way is to call:
33
34
35
36
37

.. sourcecode:: python

  self._cw.wview('slickgrid', rset, 'null')

38
Options can be specified by class attributes:
39
40

* `displaycols`, if not `None`, should be a list of rset's columns to be
Alain Leufroy's avatar
Alain Leufroy committed
41
  displayed.
42
43
44
45
46
47
48
49
50

* `headers`, if not `None`, should be a list of headers for the table's
  columns.  `None` values in the list will be replaced by computed column
  names.

* `cellvids`, if not `None`, should be a dictionary with table column index
  as key and a view identifier as value, telling the view that should be
  used in the given column.

Alain Leufroy's avatar
Alain Leufroy committed
51
52
53
54
55
56
57
As well as SlickGrid_ specific option:

* `columns_options`: a dictionary of SlickGrid column options

One can use:

.. sourcecode:: python
58

59
60
61
62
63
64
65
  class MyRsetGridView(RsetGridView):
      __regid__ = 'myslickgrid'
      headers = (_('first'), _('second'), _('third'))
      cellvids = {0: 'text', 1: 'inline', 2:'outofcontext'}
      columns_options = {0: {'sortable': False}}

  self._cw.wview('myslickgrid', rset, 'null')
66

Alain Leufroy's avatar
Alain Leufroy committed
67
Note that the pagination is not working yet.