tw2.jqplugins.jqgrid

TW2 widget wrapper the jquery ui jqgrid

Get the source from http://github.com/toscawidgets/tw2.jqplugins.jqgrid

jqGridWidget
  • options
    • Configuration options to pass to jqgrid
  • events
    • (dict) (BETA) javascript callbacks for events
  • pager_options
    • Configuration options for pager
  • prmFilter
    • params to pass to filter toolbar
  • prmEdit
    • params to pass to pager [Edit]
  • prmAdd
    • params to pass to pager [Add]
  • prmDel
    • params to pass to pager [Del]
  • prmSearch
    • params to pass to pager [Search]
  • prmView
    • params to pass to pager [View]
  • custom_pager_buttons
    • custom buttons to add to jqgrid pager
class DemoJQGridWidget(jqGridWidget):
    def prepare(self):
        self.resources.append(word_wrap_css)
        super(DemoJQGridWidget, self).prepare()
    options = {
        'pager': 'module-0-demo_pager',
        'caption': 'All research publications',
        'data': [row for row in generate_data(55)],
        'datatype': 'local',
        'colNames': ['Authors', 'Title', 'Journal', 'Published'],
        'colModel': [
            {
                'name':'authors',
                'width':50,
                'align':'center',
            }, {
                'name':'title',
            }, {
                'name':'journal',
            }, {
                'name':'published_on',
                'width':50,
                'align':'center'
            },
        ],
        'rowNum': 15,
        'rowList': [15, 30, 50],
        'viewrecords': True,
        'imgpath': 'scripts/jqGrid/themes/green/images',
        'width': 590,
        'height': 'auto',
    }
    pager_options = {"search": True, "refresh": True, "add": False, }
    prmSearch = {
        "sopt": ["cn", "bw"],
        "caption": "Search...",
        "multipleSearch": True,
    }
    custom_pager_buttons = [
        {
            "caption":"",
            "buttonicon":"ui-icon-newwin",
            'onClickButton': None,
            'position': "last",
            'title':"B1",
            'cursor':"pointer"
        }, {
            'caption': "",
            'buttonicon': "ui-icon-cart",
            'onClickButton': None,
            'position': "first",
            'title': "B2",
            'cursor': "pointer"
        },
    ]
<%namespace name="tw" module="tw2.core.mako_util"/>
<div>
<table ${tw.attrs(attrs=w.attrs)}></table>
% if w.pager_id:
    <div id="${w.pager_id}"></div>
% endif
<script type="text/javascript">
$(document).ready(
    function(){
        var opts = ${w.options | n};
        var grid = $("#${w.selector}");
        grid.jqGrid(opts);
        if ( 'pager' in opts ) {
            opts['pager_selector'] = opts['pager'];
            opts['pager'] = $(opts['pager'])
            var pager_opts = ${w._pager_options | n}
            var prmEdit = ${w._prmEdit | n};
            var prmAdd = ${w._prmAdd | n};
            var prmDel = ${w._prmDel | n};
            var prmSearch = ${w._prmSearch | n};
            var prmView  = ${w._prmView | n};
            grid.navGrid('#'+opts['pager_selector'], pager_opts,
                         prmEdit, prmAdd, prmDel, prmSearch, prmView)
            % for btn in w._custom_pager_buttons:
                .navButtonAdd('#'+opts['pager_selector'], ${btn | n})
            % endfor
            ;
        }
        % if w.prmFilter:
        var prmFilter = ${w._prmFilter | n};
        grid.jqGrid('filterToolbar', prmFilter);
        % endif
    }
);
</script>
</div>

SQLAjqGridWidget
  • options
    • Configuration options to pass to jqgrid
  • events
    • (dict) (BETA) javascript callbacks for events
  • pager_options
    • Configuration options for pager
  • prmFilter
    • params to pass to filter toolbar
  • prmEdit
    • params to pass to pager [Edit]
  • prmAdd
    • params to pass to pager [Add]
  • prmDel
    • params to pass to pager [Del]
  • prmSearch
    • params to pass to pager [Search]
  • prmView
    • params to pass to pager [View]
  • custom_pager_buttons
    • custom buttons to add to jqgrid pager
  • excluded_columns
    • list of names of columns to be excluded. This will only work if colModel is not passed.
  • datetime_format
    • format string for formatting datetime objects
  • colModel
    • list,sequence and options of columns to display
  • show_relations
    • (bool) show relationships?
  • show_attributes
    • (bool) show attributes?