If you benefit from web2py hope you feel encouraged to pay it forward by contributing back to society in whatever form you choose!


  • 0
    iiijjjiii  12 years ago
    @telloroberto: I'm not quite sure exactly what you are after. Examples above show how the contents of a cell can be formatted as a link and on clicking the link a link_handler controller function can be called with the id of the record passed along. With that you have access to all the records fields including the cell field value. JqGrid also permits calling a controller function on clicking a row within the grid. The id of the record represented in the grid row is passed along to the controller function. Here is the code from the example provided in the jqgrid application default controller.
    def callback_demo():
        """Illustrates setting the select_callback_url.
    
        When the select_callback_url is set, when a row in the jqgrid table is
        clicked, the page redirects to indicated url.
    
        JqGrid makes use of jqgrid's onSelectRow event handler.
        http://www.trirand.com/jqgridwiki/doku.php?id=wiki:events
    
        If present in the url, the placeholder '{id}' is replaced with the id of
        the record represented by the row.
        """
        response.generic_patterns = ['html']
        return dict(foo=JqGrid(
            globals(),
            db.things,
            jqgrid_options={'caption': "Click a row to trigger callback."},
            select_callback_url=URL(r=request, f='select_callback/{id}')
            )())
    
    
    def select_callback():
        """Callback for callback_demo().
    
        request.args(0): the id of the db.things record.
        """
        response.generic_patterns = ['html']
        rows = db(db.things.id == request.args(0)).select()
        return {'': BEAUTIFY(rows[0])}
    

Commented on:

Here is a JqGrid application that includes a JqGrid module that allows you to insert jqgrid tables in web2py pages using python. git clone https://iiijjjii@github.com/iiijjjii/jqgrid.git The module includes functionality for searching and form editing as well as the general features, pagination, sorting on columns, formatting and navigating available with jqgrid. The application includes examples of usage in the default.py controller.

Hosting graciously provided by:
Python Anywhere