On Monday 24 November 2008 00:16:45 simoneinweb wrote:
> As I told in my previous post [1], I've had to write a lil' bit of
> code because I need to insert links (href and javascript) into the
> rows of the ajaxgrid. This is the hack:
>
>         //BEGIN OF
> HACK
>       if(/^A\({/.test(cell_value) && /\)$/.test(cell_value))
>       {
>           var expr = cell_value.split(/,/);
>           var a_type = expr[0].replace(/^A\s*\(\s*{\s*'(\S+)'\s*:\s*'\S
> +'\s*/, "$1");
>           var url = expr[0].replace(/^A\s*\(\s*{\s*'\S+'\s*:\s*'(\S
> +)'\s*/, "$1");
>           var title = expr[1].substring(expr[1].lastIndexOf('\'', expr
> [1].lastIndexOf('\'') - 1) + 1, expr[1].lastIndexOf('\''));
>           var text = expr[2].substring(expr[2].indexOf('\'') + 1, expr
> [2].lastIndexOf('\''));
>           if (a_type == 'javascript')
>           {
>               cell_value = A({ 'javascript' : url , 'title' : title },
> text);
>           } else {
>               cell_value = A({ 'href' : url , 'title' : title },
> text);
>           }
>       }
>       //END OF HACK
>
> Place it between lines 156 and 157 in widget.js (in debian the file is
> located in /usr/share/python-support/python-turbogears/turbogears/
> static/js/widget.js). My server is currently down (damn provider :D )
> but I will upload the file as soon as possible.
>
> **use***
> If you want to insert links in the rows you have to provide the link
> in a mochikit-friendly format, such as
> A({'href' : '/home', 'title' : 'Go back Home'},  'Home')
> or
> A({'javascript' : 'myFunction()', 'title' : 'Go back Home'},  'Home')
>
> Where the 'title' field is the OnMouseOver text and the last element
> (Home in our example) is the shown text. Please pay attention to the
> symbols -->  '  <-- they are necessary.
>
> You can consider as example the following method:
>
>     @expose(format="json")
>     def summarize_problems(self):
>         rows = []
>         problems = identity.current.user.rosco_problems
>         for p in problems:
>             rows.append(["A({ 'href':'show_summary?problem_id=" + str
> (p.id) + "'," +
>                          "'title':'Modifica " + p.problem_name + "'},
> '" +
>                          p.problem_name + "')",
>                          p.problem_rows,
>                          p.problem_cols,
>                          p.problem_notes])
>         return dict(
>             headers = ["Nome del Problema", "Giorni", "Ore", "Note"],
>             rows =
> rows
>             )
>
> You can see that we are appending lists to the rows list-of-lists in
> which the first element will become a link after the rendering
> process.
>
> For the moment only text is allowed but I'm planning to allow also
> images as links.
>
> I hope that this little hack could be useful for someone.

Any reason why you don't simply do a 

table_cell = TD({})
table_cell.innerHTML = the_passed_text

?

That should allow for any html-content. 

Diez

--~--~---------~--~----~------------~-------~--~----~
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