Newbie problem with SQLAjqGridWidget - no rows

18 views
Skip to first unread message

Gary Cowell

unread,
Mar 18, 2014, 3:18:13 PM3/18/14
to turbo...@googlegroups.com
Hello

Just getting started with TurboGears 2.3.2

I've worked through a few eamples online that I've found (movies, and 'ideas' examples).

I'm having trouble getting SQLAjqGridWidget to do anything though.

I'm trying to construct a dynamic form with the widget in, my template looks like

<body>${widget.display()|n}</body>
The Forms class looks like
class myForm(tw2.forms.FormPage): title = 'My Form' class child(tw2.forms.TableForm): firstName = tw2.forms.TextField()
secondName = tw2.forms.TextField() outputgrid = StacksGrid()

And the StacksGrid class:

class StacksGrid(tw2.jqplugins.jqgrid.SQLAjqGridWidget): id = 'grid_widget' entity = model.Images excluded_columns = ['id'] prmFilter = {'stringResult': True, 'searchOnEnter': False} pager_options = {'search': True, 'refresh': True, 'add': False, } options = { 'url': '/db_jqgrid/', 'rowNum': 15, 'rowList': [15, 30, 50], 'viewrecords': True, 'imgpath': 'scripts/jqGrid/themes/green/images', 'width': 900, 'height': 'auto', } def prepare(self): # This controller registration does not generally have to occur inside # 'prepare', but we place it here so we're sure the middleware has # been initialized by tw2.devtools.dev_server before we make demands of it. mw = tw2.core.core.request_local()['middleware'] mw.controllers.register(self.__class__, 'db_jqgrid') super(StacksGrid, self).prepare()

I get an output form of my two name fields and a 'Grid Widget' header, and a 'Save' button.
There are no rows in the grid, even though the table in model.Images has two rows. I can't see any sql being performed in the log for 'gearbox serve'

I'm sorry if this seems all too simple, I feel I'm missing something obvious but at the moment, I really can't see what it is and I'd appreciate any tips about what to check.

If I'm going to guess at something, I think I'd guess at the 'url' key in the grid widget options, and the controller registration. This is a sub controller so all my URLS are /mytest/something, so I launch my form with http://localhost:8080/mytest/myformtest
So do I need mytest/ prefixing the URL in these cases? (I tried, but it made no difference, maybe I did it wrong?)
Or of course, it could be something else!
Thanks to all :)

Gary Cowell

unread,
Mar 19, 2014, 2:29:26 PM3/19/14
to turbo...@googlegroups.com
Sorry guys, I figured it out. I was missing some lines of code from the toscawidgets tutorial. Specifically the entries in config/app_config.py, specifically:

from tw2.core.middleware import ControllersApp as TW2ControllersApp

and

base_config.custom_tw2_config['controllers'] = TW2ControllersApp()
base_config.custom_tw2_config['controller_prefix'] = '/tw2_controllers/'
base_config.custom_tw2_config['serve_controllers'] = True

Thing is, I can't figure out why I didn't get any kind of error, or stack trace, or any message of any kind. Nothing to indicate what might be wrong, except the list was devoid of rows. Had column headers though :)

A secondary question might be why not? What could I have done to diagnose this, or is it just a case of 'knowing' ?

The 

Mengu

unread,
Mar 20, 2014, 5:45:47 AM3/20/14
to turbo...@googlegroups.com
that's nice, thanks for sharing! :)

by the way, we have an IRC channel #turbogears on irc.freenode.net. you might get some help from there too.
Reply all
Reply to author
Forward
0 new messages