(table,fieldname=None,fieldvalue=None,col_widths='',
               _id=None,fields='',col_width=80,width=700,height=300)
return TAG[''](TABLE(_id=_id),
                       DIV(_id=_id+"_pager"),
                       SCRIPT(script))
## Embed a jqGrid plugin
        - ``table`` is the table name
        - ``fieldname``, ``fieldvalue`` are an optional filter (fieldname==fieldvalue)
        - ``_id`` is the "id" of the DIV that contains the jqGrid
        - ``columns`` is a list of columns names to be displayed
        - ``col_width`` is the width of each column (default)
        - ``height`` is the height of the jqGrid
        - ``width`` is the width of the jqGrid
## Embed a jqGrid plugin
        - ``table`` is the table name
        - ``fieldname``, ``fieldvalue`` are an optional filter (fieldname==fieldvalue)
        - ``_id`` is the "id" of the DIV that contains the jqGrid
        - ``columns`` is a list of columns names to be displayed
        - ``col_width`` is the width of each column (default)
        - ``height`` is the height of the jqGrid
        - ``width`` is the width of the jqGrid
## Embed a jqGrid plugin - table is the table name - fieldname fieldvalue are an optional filter ( fieldname == fieldvalue ) - _id is the id of the DIV that contains the jqGrid - columns is a list of columns names to be displayed - col_width is the width of each column ( default ) - height is the height of the jqGrid - width is the width of the jqGrid
def jqgrid(table,fieldname=None,fieldvalue=None,col_widths='',
               _id=None,fields='',col_width=80,width=700,height=300):
        """
        ## Embed a jqGrid plugin
        - ``table`` is the table name
        - ``fieldname``, ``fieldvalue`` are an optional filter (fieldname==fieldvalue)
        - ``_id`` is the "id" of the DIV that contains the jqGrid
        - ``columns`` is a list of columns names to be displayed
        - ``col_width`` is the width of each column (default)
        - ``height`` is the height of the jqGrid
        - ``width`` is the width of the jqGrid
        """
        from gluon.serializers import json
        _id = 'jqgrid_%s' % table
        if fields:
            columns = [x.strip() for x in fields.split(',')]
        else:
            columns = [x.strip() for x in db[table].fields if db[table][x.strip()].readable]
        if col_widths:
            col_widths = [x.strip() for x in col_widths.split(',')]
        else:
            col_widths = [col_width for x in columns]
        colnames = columns
        colmodel = [{'name':x,'index':x, 'width':col_widths[i], 'sortable':True} \
                        for i,x in enumerate(colnames)]
        callback = URL(r=request,c='plugin_wiki',f='jqgrid',
                       vars=dict(tablename=table,
                                 columns=','.join(columns),
                                 fieldname=fieldname or '',
                                 fieldvalue=fieldvalue,
                                 ))
        script="""
jQuery(document).ready(function(){jQuery("#%(id)s").jqGrid({ url:'%(callback)s', datatype: "json", colNames: %(colnames)s,colModel:%(colmodel)s, rowNum:10, rowList:[20,50,100], pager: '#%(id)s_pager', viewrecords: true,height:%(height)s});jQuery("#%(id)s").jqGrid('navGrid','#%(id)s_pager',{search:true,add:false,edit:false,del:false});jQuery("#%(id)s").setGridWidth(%(width)s,false);});
""" % dict(callback=callback,colnames=json(colnames),
           colmodel=json(colmodel),id=_id,height=height,width=width)
        return TAG[''](TABLE(_id=_id),
                       DIV(_id=_id+"_pager"),
                       SCRIPT(script))
def jqgrid ( table , fieldname = None , fieldvalue = None , col_widths = '' , _id = None , fields = '' , col_width = 80 , width = 700 , height = 300 ) : from gluon . serializers import json _id = 'jqgrid_%s' % table if fields : columns = [ x . strip ( ) for x in fields . split ( ',' ) ] else : columns = [ x . strip ( ) for x in db [ table ] . fields if db [ table ] [ x . strip ( ) ] . readable ] if col_widths : col_widths = [ x . strip ( ) for x in col_widths . split ( ',' ) ] else : col_widths = [ col_width for x in columns ] colnames = columns colmodel = [ { 'name' : x , 'index' : x , 'width' : col_widths [ i ] , 'sortable' : True } for i , x in enumerate ( colnames ) ] callback = URL ( r = request , c = 'plugin_wiki' , f = 'jqgrid' , vars = dict ( tablename = table , columns = ',' . join ( columns ) , fieldname = fieldname or '' , fieldvalue = fieldvalue , ) ) script = """
jQuery(document).ready(function(){jQuery("#%(id)s").jqGrid({ url:'%(callback)s', datatype: "json", colNames: %(colnames)s,colModel:%(colmodel)s, rowNum:10, rowList:[20,50,100], pager: '#%(id)s_pager', viewrecords: true,height:%(height)s});jQuery("#%(id)s").jqGrid('navGrid','#%(id)s_pager',{search:true,add:false,edit:false,del:false});jQuery("#%(id)s").setGridWidth(%(width)s,false);});
""" % dict ( callback = callback , colnames = json ( colnames ) , colmodel = json ( colmodel ) , id = _id , height = height , width = width ) return TAG [ '' ] ( TABLE ( _id = _id ) , DIV ( _id = _id + "_pager" ) , SCRIPT ( script ) )