OK,
 As you probably know, you have two halves to this. You got the widget
and then you have the json call. So I use firebug to see what I am
calling for the json call.

So the first thing to do is make sure you setting the right things,
so when you change the sort order the sidx/sord items change correctly.

Assuming you are seeing the right urls for the json call, its time
to look at the data fetch method.

I had to separate column sorting and relationship sorting which I did by
capturing KeyError when looking for a column.

My code is at
https://github.com/csmall/rnms/blob/master/rnms/lib/table.py

>              'url': '/vehicle/fetch/%d' % (int(random())),
Not required, there will be a nd parameter.

>            column = getattr(Vehicle, sidx)
I'm not sure this works with relations. Also if it doesn't exist then
youll get an exception.

>        qry = qry.order_by(getattr(column,
>    sord)()).offset(offset).limit(rows).all()
So the getattr is on the column to fetch 'desc' which is a function?
ie
  Vehicle.colname.desc() 
This works only if the sort field is a real column. You'll get an error
otherwise.

I tried that way and for normal columns I was getting the expected
result. I temporarily changed do_sorting() to this:
       try:
            sort_field = getattr(self.__entity__, sort_idx)                     
                                                                      
        except AttributeError:
            return query                                                        
                                                                      
        return query.order_by(getattr(sort_field.sort_desc)())                  
                                                                      
    
And was sorting nicely.

Filtering I've locked down a lot because I wanted to use a lot of selects
rather than have people type things in. Again it gets fiddly with relationships.
I have the added problem where I wanted to hold a filter even when the user
adds one (so their additive).

 - Craig
-- 
Craig Small (@smallsees)   http://enc.com.au/       csmall at : enc.com.au
Debian GNU/Linux           http://www.debian.org/   csmall at : debian.org
GPG fingerprint:        5D2F B320 B825 D939 04D2  0519 3938 F96B DF50 FEA5

-- 
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/turbogears.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to