Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
cubicweb
cubes
slickgrid
Commits
b351b24461b3
Commit
d2b3c22d
authored
Feb 16, 2015
by
Alain Leufroy
Browse files
[views] use class attributes for options instead of kwargs
We stick to the "new-table" way of specifying options.
parent
e9ca9c8f6ed3
Changes
2
Hide whitespace changes
Inline
Side-by-side
README
View file @
b351b244
...
...
@@ -35,8 +35,7 @@ The simplest way is to call:
self._cw.wview('slickgrid', rset, 'null')
Although, because it inherites from cubicweb `table` view, options can
be specified at selection time:
Options can be specified by class attributes:
* `displaycols`, if not `None`, should be a list of rset's columns to be
displayed.
...
...
@@ -57,9 +56,12 @@ One can use:
.. sourcecode:: python
self._cw.wview('slickgrid', rset, 'null',
headers=(_('first'), _('second'), _('third')),
cellvids={0: 'text', 1: 'inline', 2:'outofcontext'},
columns_options={0: {'sortable': False}})
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')
Note that the pagination is not working yet.
\ No newline at end of file
views.py
View file @
b351b244
...
...
@@ -144,28 +144,22 @@ class RsetGridView(tableview.RsetTableView):
result set to compute column names and the proper way to display
the cells.
It is highly configura
tion
and accepts the same wealth of option than
:class:`cubicweb.web.view.tableview.RsetTableView` plus the following
s
:
It is highly configura
ble
and accepts the same wealth of option than
:class:`cubicweb.web.view.tableview.RsetTableView` plus the following:
* `default_grid_options`: a dictionary containing slickgrid grid
options, see https://github.com/mleibman/SlickGrid/wiki/Grid-Options
* `default_column_options`: slickgrid option applied to every
column
s
, see
* `default_column_options`: slickgrid option
s
applied to every
column
by default
, see
https://github.com/mleibman/SlickGrid/wiki/Column-Options
* `columns_options`: a dictionary referencing a column index to a
dict of slickgrid # column options. This completly overri
ght
the
dict of slickgrid # column options. This complet
e
ly overri
des
the
default column options set in `default_column_options`.
`columns_options` can be set at selection time.
"""
__regid__
=
'slickgrid'
# The default selector of RsetTableView try to deal with TableView
# backward compat by selecting RsetTableView with exact matching kwargs
# but we want to accept additional kwargs.
__select__
=
tableview
.
AnyRsetView
.
__select__
layout_id
=
'slickgrid_layout'
default_column_renderer_class
=
RsetGridColRenderer
handle_pagination
=
False
# pagination does not works well for now
...
...
@@ -180,13 +174,11 @@ class RsetGridView(tableview.RsetTableView):
default_column_options
=
{
'focusable'
:
False
}
columns_options
=
None
def
call
(
self
,
columns_options
=
None
,
**
kwargs
):
self
.
columns_options
=
columns_options
or
self
.
columns_options
or
{}
super
(
RsetGridView
,
self
).
call
(
**
kwargs
)
def
get_column_options
(
self
,
colid
):
'''Return a dictionary containing'''
column_options
=
self
.
columns_options
.
get
(
colid
,
{})
if
not
column_options
:
column_options
=
self
.
default_column_options
if
self
.
columns_options
is
None
:
return
self
.
default_column_options
column_options
=
self
.
columns_options
.
get
(
colid
,
None
)
if
column_options
is
None
:
return
self
.
default_column_options
return
column_options
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment