Hans,

Here is a skeleton. I have one minor issue I will detail at the end.
--

View:
In Web2py_ajax.html add --

<link href="{{=URL(r=request,c='static',f='demos.css')}}"
rel="stylesheet" type="text/css" media="screen" charset="utf-8" />
<script src="{{=URL
(r=request,c='static',f='jquery.dataTables.min.js')}}" type="text/
javascript"></script>

Static:
Add --

demo.css
jquerydataTables.min.js
jpgs from the dataTables package


Controller:

def list():
    # Setup environment
    import gluon.contrib.simplejson as sj
    json = ""
    list = []

#Modify this to use a Model of your choosing.
    rows = dbhlx().select
(dbhlx.contact.id,dbhlx.contact.lastname,dbhlx.contact.firstname,dbhlx.contact.phone,orderby=dbhlx.contact.lastname)
    # Format and serialize the query for use by dataTables
    numrows = len(rows) - 1
    json = "{aaData: [\r\n"
    for row in rows:
        list.append(row.id)                            # Replace with
your own model vars.
        list.append(row.lastname)
        list.append(row.firstname)
        list.append(row.phone)
        if numrows :
            json += sj.dumps(list) + ",\r\n"
        else:
            json += sj.dumps(list) + "\r\n"
        list = []
        numrows -= 1
    json += "\r\n]}\r\n"


    # write file out
    FILE = open("../Helix/applications/Helix/static/
contacts.json","w")
    FILE.writelines(json)
    FILE.close()
    return dict()

View:

{{extend 'layout.html'}}
<h1>Contacts</h1>


<!--- Load table via Ajax call --->
<form>
<input id="begin" value="A" type="hidden">
<input id="end" value="Z" type="hidden">
<input onload="ajax('{{=URL(r=request,f='list')}}',
['begin','end'],'');" type="hidden">
</form>
<br></br>

<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
    $('#example').dataTable( {
        "bProcessing": true,
        "sAjaxSource": "{{=URL
(r=request,c='static',f='contacts.json')}}"
    } );
} );
</script>

<div id="dynamic">
<table  id='example' cellpadding="0" cellspacing="0" border="0"
class="display">
    <thead>
        <tr>
            <th>ID</th>
            <th>Last Name</th>
            <th>First Name</th>
            <th>Phone</th>
        </tr>
    </thead>
    <tbody>

    </tbody>
    <tfoot>
        <tr>
            <th>ID</th>
            <th>Last Name</th>
            <th>First Name</th>
            <th>Phone</th>
        </tr>
    </tfoot>
</table>
</div>

I use the aaData method above to populate the table. It expects a JSON
table that I generate and write out in the controller. The plus is
that I don't have to go back to the database for pagination. There is
a second technique I have not dipped into yet. Need to finalize this
work in progress first.

The single issue I have is that the jpgs do not display which I assume
is a mismatch on my part from what dataTables expects and where I have
them placed. Has anyone cracked this issue?

Hope this helps.

JohnMc

On May 10, 1:51 pm, Hans <johann.scheibelho...@easytouch-edv.com>
wrote:
> I'd love to get dataTable/JEditable included and working on a web2py
> app, especially since it should be easy. Unfortunately I dont know how/
> where to start. It would be great if someone of the experts could
> explain what steps are required!
>
> On 9 Mai, 21:03, mdipierro <mdipie...@cs.depaul.edu> wrote:
>
> > I have used dataTable but I never tried jEditable. Should be easy to
> > do.
>
> > On May 9, 12:03 pm, Hans <johann.scheibelho...@easytouch-edv.com>
> > wrote:
>
> > > Has anyone managed to implement a editable grid into web2py, something
> > > likehttp://datatables.net/examples/example_editable.html?
> > > If so could you share a full (working!) example ?
>
> > > Hans
>
> > > On 8 Mai, 14:46, mdipierro <mdipie...@cs.depaul.edu> wrote:
>
> > > >http://www.ajaxline.com/10-best-jquery-plugins-for-working-with-tables
>
> > > > On May 8, 4:08 am, Álvaro Justen [Turicas] <alvarojus...@gmail.com>
> > > > wrote:
>
> > > > > Click on table headers to orderby and in a row to select it 
> > > > > (client-side):http://google-visualization.appspot.com/python/static_example
>
> > > > > Project's site:http://code.google.com/p/google-visualization-python/
>
> > > > > --
> > > > >  Álvaro Justen
> > > > >  Peta5 - Telecomunicações e Software Livre
> > > > >  21 3021-6001 / 9898-0141
> > > > >  http://www.peta5.com.br/
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to