entity = model.Person excluded_columns = ['id', 'job_id'] options = { 'url': '/db_jqgrid/', 'editurl': '/db_jqgrid/', 'rowNum': 15, 'rowList': [15, 30, 50], 'viewrecords': True, 'imgpath': 'scripts/jqGrid/themes/green/images', 'width': 590, 'height': 'auto', 'pager': 'module-1-demo_pager', } prmFilter = {'stringResult': True, 'searchOnEnter': False} pager_options = { "search": False, "refresh": True, "add": True, "del": False, } import tw2.core as twc twc.register_controller(DemoSQLAJQGridWidget, 'db_jqgrid')
options = { 'value' : 28 } class DemoSliderWidget(SliderWidget): pass # For this tabs widget, let's conveniently re-use the data from the # AccordionWidget, but change the third option to load its data via ajax! ajaxified_tabs_items = [{'label': v[0], 'content': v[1]} for v in some_items] ajaxified_tabs_items[2]['label'] += ' (via ajax)' ajaxified_tabs_items[2]['href'] = '/ajaxtab/' del ajaxified_tabs_items[2]['content'] class DemoTabsWidget(TabsWidget): items = ajaxified_tabs_items @classmethod def request(cls, req): # You could, of course, use other controllers (say a tg2 controller) import time import webob time.sleep(1) resp = webob.Response(request=req, content_type="text/html") resp.body = "<p>wow.. this came via <h4>ajax!</h4></p>" return resp # Register the widget's controller import tw2.core as twc twc.register_controller(DemoTabsWidget, 'ajaxtab')
# {"title": "Folder 2", "key": "2", "folder": True, # "children": [ # {"title": "Node 2.1", "key": "3"}, # {"title": "Node 2.2", "key": "4"}, # {"title": "Node 2.3", "key": "5"} # ] # }, # ] # # 2. drawing the data directly from taxonomy_tree(), the data # will be rendererd directly within the page's html #'source': taxonomy_tree() # # 3. simulated ajax call 'source': {'url': 'jsonsource', 'cache': False}, } @classmethod def request(cls, req): import webob import time # the artificial delay demos that `loading` is displayed by # the widget time.sleep(1) resp = webob.Response(request=req, content_type="application/json") resp.body = json.dumps(taxonomy_tree()) return resp # register the widget's request twc.register_controller(DemoFancyTreeWidget, 'jsonsource')
super(DemoSQLAJQGridWidget, self).prepare() entity = model.Person excluded_columns = ['id', 'job_id'] options = { 'url': '/db_jqgrid/', 'editurl': '/db_jqgrid/', 'rowNum': 15, 'rowList': [15, 30, 50], 'viewrecords': True, 'imgpath': 'scripts/jqGrid/themes/green/images', 'width': 590, 'height': 'auto', 'pager': 'module-1-demo_pager', } prmFilter = {'stringResult': True, 'searchOnEnter': False} pager_options = { "search": False, "refresh": True, "add": True, "del": False, } import tw2.core as twc twc.register_controller(DemoSQLAJQGridWidget, 'db_jqgrid')