문제

I have this below code in view of web2py

{{extend 'layout.html'}}
{{import xml.etree.ElementTree as ET}}
{{import json}}
<style type="text/css">
.myTable { width:100%;background-color:#eee;border-collapse:collapse; }
.myTable TH { background-color:#8B0000;color:white;width:50%; }
.myTable TD, .myTable TH { padding:5px;border:1px solid #000; text-align:Center }
</style>
<table class="myTable">
    {{=TABLE(THEAD(TR([TH(c) for c in colnames])),
        [TR(row) for row in rows])}}
</table>
{{=BEAUTIFY(response._vars)}}
  1. But, I am not sure why I am not able to see CSS being used while displaying output. CSS effect is not seen
  2. Also, I am returning colnames and rows in controller as

return dict(colnames = colnames, rows = rows)

Not sure why I am getting values in colnames and rows list when I call view html in web2py? It is printing tables and also values in colnames and rows.

도움이 되었습니까?

해결책

{{=TABLE(THEAD(TR([TH(c) for c in colnames])),
         [TR(row) for row in rows])}}

The above already produces a table (that's what the TABLE helper does), so you are wrapping one table element inside another -- that is, the HTML will look like:

<table class="myTable">
    <table><thead><tr><th>...
    </table>
</table>

Instead, just add the "myTable" class to the TABLE helper:

{{=TABLE(THEAD(TR([TH(c) for c in colnames])),
         [TR(row) for row in rows],
         _class='myTable')}}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top