|
- import win.ui;
- /*DSG{{*/
- mainForm = win.form(text="aardio form";right=973;bottom=619)
- mainForm.add()
- /*}}*/
- import web.layout;
- wbLayout = web.layout(mainForm)
- //wbLayout.go("/test.html")
- wbLayout.html = /**
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>Document</title>
- </head>
- <body>
- <widget type="select" id="report">
- <table>
- <thead>
- </thead>
- <tbody>
- </tbody>
- </table>
- </widget>
- </body>
- <div id="show"></div>
- </html>
- **/
- wbLayout.css = /**
- html body {
- margin: 0;
- padding: 0;
- font-family: '微软雅黑', '宋体';
- overflow: hidden;
- }
- #report {
- size: *;
- overflow: auto;
- }
- table {
- size: 100%%;
- border-spacing: 0;
- }
- table thead {
- height: 30px;
- }
- table thead th {
- border: rgb(75, 75, 77) solid 1px;
- background-color: #eee;
- }
- table thead tr {
- font-size: 1.3em;
- background-color: #A7C942;
- }
- table tbody tr {
- color: #000000;
- background-color: #EAF2D3;
- height: 1.8em;
- font-size: 1.3em;
- }
- table tbody td {
- text-align: center;
- height: 1.8em;
- border: rgb(75, 75, 77) solid 1px;
- padding: 0;
- }
- #show {
- margin: 20px;
- }
- }
- **/
- thead = {"id";"姓名";"性别";"年龄";"籍贯"}
- tpl = /*
- <? var data = ...; ?>
- <tr>
- <? for(i=1;#data;1){ ?>
- <th> <? =data[ i ] ?> </th>
- <?}?>
- </tr>
- */
- wbLayout.$1("thead").printf("%s",string.loadcode(tpl,thead))
- tbody = {
- {name="张三";sex="男";age=33;jg="山东"};
- {name="李四";sex="女";age=19;jg="河北"};
- {name="王五";sex="男";age=25;jg="山西"};
- }
- var tr=""
- for(i=1;#tbody;1){
- tr+="<tr><td>"+i+"</td><td>"+tbody[ i ].name+"</td><td>"+tbody[ i ].sex+"</td><td>"+tbody[ i ].age+"</td><td>"+tbody[ i ].jg+"</td></tr>"
- }
- wbLayout.$1("tbody").insertAdjacentHTML("beforeEnd",tr)
- var col = wbLayout.$("thead th");
- var str = ""
- for(i=1;#col;1){
- str++=`<span><input type="checkbox" checked="checked" id="`+i+`"/>`+col[ i ].innerText+`</span>`;
- }
- wbLayout.$1("#show").printf("配置表头字段:%s",str);
- wbLayout.onButtonClick = function (ltTarget,ltOwner,reason,behaviorParams) {
- var chk = wbLayout.$(`input[type="checkbox"]`)
- var rootTr = wbLayout.$1("table")
- for(i=1;#chk;1){
- if (!chk[ i ].state.checked){
- rootTr.enumQuery(
- function(ltEle){
- ltEle.child(i).style["display"] = "none";
- },"tr"
- )
- }else{
- rootTr.enumQuery(
- function(ltEle){
- ltEle.child(i).style["display"] = "block";
-
- },"tr"
- )
- }
- }
- }
- mainForm.show();
- return win.loopMessage();
复制代码 |
|