Commits

Ralph Bean committed c900ff8

Getting way fancy.

Comments (0)

Files changed (4)

myapp/myapp/__init__.py

     config.add_view('myapp.views.view_widget',
                     context='myapp.widgets.MovieForm',
                     renderer="templates/widget.pt")
-
     config.add_view('myapp.views.view_widget',
                     context='myapp.widgets.MovieList',
                     renderer="templates/widget.pt")
+    config.add_view('myapp.views.view_grid_widget',
+                    context='myapp.widgets.GridWidget',
+                    renderer="templates/widget.pt")
 
     return config.make_wsgi_app()
 

myapp/myapp/models.py

             w.__parent__ = self
             w.__name__ = key
             return w
+        if key == 'grid':
+            import myapp.widgets
+            w = myapp.widgets.GridWidget.req()
+            w.__parent__ = self
+            w.__name__ = key
+            return w
 
         session= DBSession()
         try:

myapp/myapp/views.py

     mw = tw2.core.core.request_local()['middleware']
     mw.controllers.register(context, 'movie_submit')
     return {'widget':context}
+
+def view_grid_widget(context, request):
+    mw = tw2.core.core.request_local()['middleware']
+    mw.controllers.register(context, 'db_jqgrid')
+    return {'widget':context}

myapp/myapp/widgets.py

 import tw2.forms
 import tw2.sqla
 import tw2.dynforms
+import tw2.jqplugins.jqgrid
 
 import myapp.models
 
     class child(tw2.forms.GridLayout):
         title = tw2.forms.LabelField()
         id = tw2.forms.LinkField(link='/movie?id=$', text='Edit', label=None)
+
+class GridWidget(tw2.jqplugins.jqgrid.SQLAjqGridWidget):
+    id = 'grid_widget'
+    entity = myapp.models.Movie
+    excluded_columns = ['id']
+    prmFilter = {'stringResult': True, 'searchOnEnter': False}
+    pager_options = { "search" : True, "refresh" : True, "add" : False, }
+    options = {
+        'url': '/tw2_controllers/db_jqgrid/',
+        'rowNum':15,
+        'rowList':[15,30,50],
+        'viewrecords':True,
+        'imgpath': 'scripts/jqGrid/themes/green/images',
+        'width': 900,
+        'height': 'auto',
+    }
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.