I am trying to build a table from a joined set of db tables and need to do quite a bit of processing to make the links and buttons in each row. Making the code readable is important to me so I do not want to put one giant long line of code to do everything and make it impossible for another person to make changes without breaking it for hours on end. I am not sure a one-liner is possible with all the looping anyway.
So what I do is build up each row in a loop and concatenate the strings together. I then build the thead and tbody and stick it all in a table using the TABLE helper. The TABLE helper and the TBODY helper both see that I do not have the TR helper as inputs and so it adds the <tr><td> making my table incorrect. I also tried putting the THEAD and TBODY inside the TABLE helper directly, but the TBODY does the same thing and still screws it up. Is there any way to suppress the TR requirement, or fix it to see that my XML object passed contains the required <tr> instead of assuming that since I didn't use the helper it is needed? I dug around in the code a bit to see if I could find it and make a change, but alas I am just a hack and all I could find in the code was the TABLE class and not where any of the code actually does anything. If someone could point me to that code I would have a look at it. Is there some other way to workaround this still using the helpers that doesn't involve building the entire thing in one giant hodge podge of code that is impossible to read? Here is my python in the controller that builds the table HTML: #these three lines are static, but in my code the looping that builds them is pretty complex eventually with form elements, javascript, and links htmlrows="<tr><td>row 1 desc</td><td><a href='#'>row 1 link</a></td><td>a</td></tr>" htmlrows+="<tr><td>row 2 desc</td><td><a href='#'>row 2 link</a></td><td>b</td></tr>" htmlrows+="<tr><td>row 3 desc</td><td><a href='#'>row 2 link</a></td><td>c</td></tr>" htmltablehead=XML(THEAD(TR(TH('Column 1'),TH('links'),TH('column 3')))) htmltablebody=XML(TBODY(XML(htmlrows))) htmltable=XML(TABLE(XML(htmltablehead),XML(htmltablebody),_class="pure-table pure-table-bordered")) and then finally in the view I have this: {{=XML(htmltable)}} This is the output of the table and the orange and red are screwing up the rendering by the browser. <table class="pure-table pure-table-bordered"> <tr><td> <thead> <tr><th>Column 1</th> <th>links</th> <th>column 3</th> </tr> </thead> </td></tr> <tr><td> <tbody> <tr><td> <tr><td>row 1 desc</td><td><a href='# <https://plc-labs.net/welcome/default/index2#>'>row 1 link</a></td><td>a </td></tr> <tr><td>row 2 desc</td><td><a href='# <https://plc-labs.net/welcome/default/index2#>'>row 2 link</a></td><td>b </td></tr> <tr><td>row 3 desc</td><td><a href='# <https://plc-labs.net/welcome/default/index2#>'>row 2 link</a></td><td>c </td></tr> </td></tr> </tbody> </td></tr> </table> -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.