Don wrote:
> By now, I've had a few weeks experience with Turbogears.
>
> I am trying to implement a sortable DataGrid.
>
> I have implemented a partial solution, but it is inadequate.
> For each SQLObject/table I've defined in my model.py, I've created
> a corresponding controller and kid template which displays
> the data for each table as a datagrid.  Sorting is done
> by the user choosing from a list of columns in a pull-down
> menu.  The pull-down menu is populated by retrieving the list
> columns for table with a call to [SQLObect].sqlmeta.columns.keys().
> When the user submits the form, the selected column is passed to
> the controller, which then does a [SQLObject].select(orderBy=sortTerm)
> to
> retrieve the data for the updated DataGrid.
>
> The problem with my implementation is that some of the data
> in my data grids is dynamic.  For example, the hostname field
> in my Hardware SQLObject is set like this:
>
>   hostname = property(__calculate_hostname)
>
> where __calculate_hostname is a method.  So the actual values for that
> field are not calculated and added to my gridData object until I call
> ${ grid.display( gridData ) } in my kid.  Setting orderBy=hostname
> does
> not seem to cause the __calculate_hostname method to be invoked
> during the sort, and by the time I call grid.display( gridData ), it
> is too
> late for a custom sort (?).  If anyone has followed me until now, do
> you
> know how I could sort those dynamically-generated columns as well?
>
> As you can see, I'm deep in the details of one possible
> implementation for sorting DataGrid tables problem.  At this
> point, I am wondering if I'm making this more difficult than it
> needs to be.
>
> I have found a different implementation of sortable DataGrid
> columns using mochikit at:
> http://mochikit.com/examples/sortable_tables/index.html
> But I when I try to follow the example, Turbogears fails
> to parse my template once it gets to the <th mochi:format="str">
> construct.  I have tried putting the <link> and <script>
> lines at the top of my template to import MochiKit.js,
> sortable_tables.css, and sortable_tables.js.  Is there
> something else I need to allow Turbogears to parse the
> <th mochi:format ...  lines?  I can send my .kid if anyone
> would like to see that.
>
> I am using TurboGears-1.0.3.2 with Python 2.5.
>
> I know this question about sorting DataGrid tables has been
> asked a lot in the past, so I apologize for asking it again.
> However, I'm afraid that since I'm still quite new to Turbogears,
> without a full example, I don't understand how to put all the
> pieces come together.
>
> If anyone knows of any Web sites that have lots of examples
> of using MochiKit, particularly sites that include examples of
> MochiKit constructs being integrated and used in
> existing templates, I'd really appreciate your pointers.
>
>
> >
>   
I use PageinateDataGrid to do this with the clickable column headings.  
However, when I have a derived column on which I need to sort, I resort 
to creating a view in my database (an an associated SQLObject object to 
reference it) and have the view derive the value.  Not an ideal 
solution, but it works for me.

    -Jim


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to