Hallo Neveen,

On 26 April 2011 17:48, Neveen Adel <[email protected]> wrote:

> Hello,
>
>  Is there a way to export the data resulting in plugin_jqgrid?


What I normally do is:

In my controller:

def list_data():
    data=plugin_wiki.widget('jqgrid', table='joernaal', col_width=130,
width= 1000)

    if request.extension == 'csv':
        rows = db(db.joernaal.id>0).select()
        return str(rows) # as csv
    link =
A('download',_href=URL(r=request,f='joernale.csv',vars=request.vars))

    return dict(data = data, ,link = link)

 joernale=plugin_wiki.widget('jqgrid', table='joernaal', col_width=130,
width= 1000)


Then I would have  two views: list_data.html(showing grid as well as a
'Download' link) and list_data.csv which contains:

{{
import cStringIO
stream=cStringIO.StringIO()
rows.export_to_csv_file(stream)
response.headers['Content-Type']='application/vnd.ms-excel'
response.write(stream.getvalue(), escape=False)
}}



> And
> also how can i display a records with a specific criteria in a table
> instead of displaying all records by default?
>
>
You can use a simple filter but not as far as I know complex queries.
Search for jqgrid in the Book where it is documented:

 http://web2py.com/book/default/chapter/13?search=yrtable

Regards
Johann


-- 
 May grace and peace be yours in abundance through the full knowledge of God
and of Jesus our Lord!  His divine power has given us everything we need for
life and godliness through the full knowledge of the one who called us by
his own glory and excellence.
                                                    2 Pet. 1:2b,3a

Reply via email to