Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

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.8.1

Use as a grid

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('movie_list', url='fetch', caption='Movies',
            colNames=colNames, colModel=colModel,
            rowList=[5,10], rowNum=5,
            sortname='title',
            viewrecords=True,
            width='auto',
            height='auto',
            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:

from math import ceil

@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 = getattr(Movie, field)
        if searchOper == u'cn':
            q = medias_q.filter(field_attr.contains(searchString))
        if searchOper == u'bw':
            q = q.filter(field_attr.startswith(searchString))

    result_count = medias_q.count()
    total = int(ceil(result_count / float(rows))) # total nb of pages
    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)

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 theme

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>

with contributions from

  • Tuomas Peltonen

Change history

New in 0.3

0.3 added parameters to use the grid as a jqTreeGrid more events supported

New in 0.2

0.2 now relies on the 3.8.2 version of the js lib

New in 0.1

0.1b1 added parameter for edit url

0.1a4 sortorder has “asc” as default value better example in readme

0.1a3 added sortorder param to allow setting of default order thanks to : Tuomas Peltonen

0.1a2 added parameters for subgrids

0.1a1 added dependency on tw.uitheme for design

0.1a0 First Release

Metadata

Release files for tw.jqgrid 0.3dev-20110207

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tw.jqgrid 0.3dev-20110207
File Size Uploaded
tw.jqgrid-0.3dev-20110207.tar.gz 503.0 kB Details

Release files / tw.jqgrid-0.3dev-20110207.tar.gz

Download URL tw.jqgrid-0.3dev-20110207.tar.gz
Size 503.0 kB
Tags Source
SHA-256 checksum
How to use checksums
2f3d214ab60199a1ae5db039461000ff3090dfe99014615eb00a0254b3f28279
BLAKE2b-256 checksum
How to use checksums
90c91b4565e764948b246b3bc5423bb9fd3b96a530517af02ccea06280b09caa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page