sure,
I am using the YUI tree to display a tree of assets and thier associated
children, i.e. the 'Devices' node of the tree has 'www.acme.com' and '
db1.acme.com' underneath it. Clicking on the tree parent utilizes the
builtin YUI function to expand the tree which sends an async (Xml HTTP
Request aka AJAX) request to a view which returns the nodes and is
populated. However, when the user clicks on a childless node such as '
www.acme.com' an XHR request is sent to a view which, after verifying some
security parameters, creates a newform of the device, gets associated
history records, assessment records, and messages for the device and then
uses a number of render_to_response calls ala:
form = render_to_response('device_form_template.html', {'form': f})
The view then creates tables for the related records (history, assessments,
messages) ala:
a = obj.assessments.all()
assessment_table = render_to_response('assessment_table.html':
{'assessment': a})
This template formats the assessment, history, and message information into
3 raw html tables
the view then takes all of these components (the tables and the form) and
bundles it into a response dictionary
response_dict.update{'form': form._container, 'assessment_table':
assessment_table, messages, history... )
and returned: via
HttpResponse(simplejson.dumps(response_dict), mimetype =
'application/javascript')
My javascript callback function then unpacks the json object and puts the
forms and the three tables into one of four tabs on a tab panel on the right
2/3rd of the screen. As I said I am using the YUI so I can easily transform
the three tables into Yahoo User Interface Datatables which allow sorting
and scrolling and all that stuff really easily.
I hope this explanation has been clear enough, but I can post a sample if
you would like, let me know which piece is most puzzling (view, template,
javascript)
-richard
On 9/14/07, robo <[EMAIL PROTECTED]> wrote:
>
>
> Hi Richard,
>
> Can you give an example of what you are suggesting?
>
> > One thing that you can do is to pass a
> > render_to_response call a template and the python dictionary you want
> > modified and let django work its majic on it before returning the
> > '._container' to the page via json.
>
> Thanks.
>
> To Olivier: Iterating through javascript like that is possible, but it
> poses a disadvantage in that I cannot access the data's related object
> (e.g. ForeignKey relationships).
> For example I can do data[0].fields.user and I'd get "3" as a
> response, but I cannot do data[0].fields.user.username, where user is
> a foreignkey. Whereas in Django I can do something like this:
> manager.user.username and I'd get the user name.
>
> Thanks for the responses, all.
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" 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/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---