tosca widget wrapper around jqgrid library
Project description
.. contents::
Detailed Documentation
**********************
tw.jqgrid documentation
=======================
tw.jqmultiselect is a tosca widget wrapper around jquery grid plugin
which can be found here :
`http://www.trirand.com/blog/`_
the version released with this package is 3.7.2
in the view controller ::
from tw.jqgrid import JqGrid
colNames = ['ID','Title', 'Synopsis']
colModel = [
{'name':'id', 'index':'id', 'width':20, 'align':'right'},
{'name':'title', 'index':'title','width':100, 'align':'left'},
{'name':'synopsis', 'index':'synopsis','width':580, 'align':'left', 'sortable':False},
]
search_options = {
"caption": "Search...",
"Find": "Find",
"Reset": "Reset",
"sopt" : ['cn', 'bw'],
"closeOnEscape":True,
}
navbuttons_options = {
"view":False,
"edit": False,
"add": False,
"del": False,
"search":True,
"refresh":True,
}
grid_local = JqGrid(id='movie_list', url='fetch', caption='Movies',
colNames=colNames, colModel=colModel,
rowList=[5,10], rowNum=5,
sortname='title',
viewrecords=True,
autowidth=True,
shrinkToFit=True,
search_options = search_options,
navbuttons_options = navbuttons_options,
)
class MoviesController(BaseRestController):
@expose('project.templates.movies.get_all')
def get_all(self):
pylons.c.grid = grid_local
return dict(page='all movies')
in the template::
${tmpl_context.grid()}
now to feed data we need a controller::
@expose('json')
def fetch(self, page=1, rows=10, sidx=1, sord='asc', _search='false',\
searchOper=u'', searchField=u'', searchString=u'', **kwargs):
offset = (int(page)-1) * int(rows)
q = Movie.query
search_bool = eval(_search.capitalize())
if (search_bool):
field = str(searchField)
field_attr = Movie.__getattribute__(Movie, field)
if searchOper == u'cn':
q = medias_q.filter(field_attr.like(u'%%%s%%' % searchString))
if searchOper == u'bw':
q = q.filter(field_attr.like(u'%s%%' % searchString))
result_count = medias_q.count()
total = 1 + result_count / int(rows)
column = getattr(Movie.table.c, sidx)
movies = q.order_by(getattr(column,sord)()).offset(offset).limit(rows)
rows = [{'id' : movie.id,
'cell': [movie.id, '<a href="/medias/%s/">%s</a>' % (movie.id, movie.title),
movie.synopsis]} for movie in movies]
return dict(page=page, total=total, records=result_count, rows=rows)
.. note:: this is written for an elixir model, adapt to your need
design it:
tw.jqgrid rely on tw.uitheme for its design, the smooth theme is the default
you can use any other theme, or roll your own `http://jqueryui.com/themeroller/`_
below a code snippet on how to do that::
from tw.uitheme import lefrog_css, peppergrinder_css
from tw.jqgrid import jqgrid_css, jqgrid_search_css
class CustomGrid(JqGrid):
css = [peppergrinder_css, jqgrid_css, jqgrid_search_css]
grid_local = CustomGrid(.....
Contributors
************
Main developpers
================
* Nicolas Laurance <nicolas[dot]laurance[at]gmail[dot]com>
Change history
**************
New in 0.1
==========
0.1a2
addes parameters for subgrids
0.1a1
added dependency on tw.uitheme for design
0.1a0
First Release
Detailed Documentation
**********************
tw.jqgrid documentation
=======================
tw.jqmultiselect is a tosca widget wrapper around jquery grid plugin
which can be found here :
`http://www.trirand.com/blog/`_
the version released with this package is 3.7.2
in the view controller ::
from tw.jqgrid import JqGrid
colNames = ['ID','Title', 'Synopsis']
colModel = [
{'name':'id', 'index':'id', 'width':20, 'align':'right'},
{'name':'title', 'index':'title','width':100, 'align':'left'},
{'name':'synopsis', 'index':'synopsis','width':580, 'align':'left', 'sortable':False},
]
search_options = {
"caption": "Search...",
"Find": "Find",
"Reset": "Reset",
"sopt" : ['cn', 'bw'],
"closeOnEscape":True,
}
navbuttons_options = {
"view":False,
"edit": False,
"add": False,
"del": False,
"search":True,
"refresh":True,
}
grid_local = JqGrid(id='movie_list', url='fetch', caption='Movies',
colNames=colNames, colModel=colModel,
rowList=[5,10], rowNum=5,
sortname='title',
viewrecords=True,
autowidth=True,
shrinkToFit=True,
search_options = search_options,
navbuttons_options = navbuttons_options,
)
class MoviesController(BaseRestController):
@expose('project.templates.movies.get_all')
def get_all(self):
pylons.c.grid = grid_local
return dict(page='all movies')
in the template::
${tmpl_context.grid()}
now to feed data we need a controller::
@expose('json')
def fetch(self, page=1, rows=10, sidx=1, sord='asc', _search='false',\
searchOper=u'', searchField=u'', searchString=u'', **kwargs):
offset = (int(page)-1) * int(rows)
q = Movie.query
search_bool = eval(_search.capitalize())
if (search_bool):
field = str(searchField)
field_attr = Movie.__getattribute__(Movie, field)
if searchOper == u'cn':
q = medias_q.filter(field_attr.like(u'%%%s%%' % searchString))
if searchOper == u'bw':
q = q.filter(field_attr.like(u'%s%%' % searchString))
result_count = medias_q.count()
total = 1 + result_count / int(rows)
column = getattr(Movie.table.c, sidx)
movies = q.order_by(getattr(column,sord)()).offset(offset).limit(rows)
rows = [{'id' : movie.id,
'cell': [movie.id, '<a href="/medias/%s/">%s</a>' % (movie.id, movie.title),
movie.synopsis]} for movie in movies]
return dict(page=page, total=total, records=result_count, rows=rows)
.. note:: this is written for an elixir model, adapt to your need
design it:
tw.jqgrid rely on tw.uitheme for its design, the smooth theme is the default
you can use any other theme, or roll your own `http://jqueryui.com/themeroller/`_
below a code snippet on how to do that::
from tw.uitheme import lefrog_css, peppergrinder_css
from tw.jqgrid import jqgrid_css, jqgrid_search_css
class CustomGrid(JqGrid):
css = [peppergrinder_css, jqgrid_css, jqgrid_search_css]
grid_local = CustomGrid(.....
Contributors
************
Main developpers
================
* Nicolas Laurance <nicolas[dot]laurance[at]gmail[dot]com>
Change history
**************
New in 0.1
==========
0.1a2
addes parameters for subgrids
0.1a1
added dependency on tw.uitheme for design
0.1a0
First Release
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Close
Hashes for tw.jqgrid-0.1a2dev-20100730.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | cace9e09a6c43008b692dcc3d01d0228c2a8c59e1f8a684e3ef9d1cafa2c054f |
|
MD5 | ce01bb0ed8b4959a37370eed94b3187f |
|
BLAKE2b-256 | e591f7a9a0b5497db3149761ccf97535d85ceec574a87b5de4ac51923e8d45b1 |