作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
如果有一个表,最后一列称为结果。我想突出显示所有“失败”的单元格/文本。
我该怎么做?
我需要将 html5 与 kdb 中的表格一起使用。
目前我的邮件功能是这样的
htmlMailBody:{[emailadd;subject;message]
cmd:"echo \"",message, "\" | mutt -e \"my_hdr
From:abc@gmail.com\" -e \"my_hdr Content-Type:
text/html\" ",emailadd, " -s \"",subject,"\"";
sent:@[{system x;1b};cmd;{.log.error"Failure sending email. Reason: ",x;0b}];
if[sent; .log.info "Sent email to ",emailadd ];
};
mailRCP:bbc.gmail.com
htmlMailBody[mailRCP ;"health check";(,/)("<h2>SOD CHECKS<hr /></h2>";"<br />";markup[result];"<br />")];
这没有用。如果将 markup[result] 替换为 kdb 表,它将起作用。
最佳答案
要直接从 q 标记您的 HTML 表格,请使用 .h
namespace 中的标记函数.
让你的表成为t
。
q)t
a b c d result
-------------------
94 66 8 82 success
8 24 62 47 failed
97 60 95 26 success
52 69 59 93 success
为 HTML td
元素制作一个相应的属性表 at
。从空字典开始,没有属性。空字典是 ()!()
。
q)show at:flip (cols t)! (count each(cols t;t))#enlist ()!()
a b c d result
------------------------------
()!() ()!() ()!() ()!() ()!()
()!() ()!() ()!() ()!() ()!()
()!() ()!() ()!() ()!() ()!()
()!() ()!() ()!() ()!() ()!()
根据t
的result
列更新at
的result
列。
q)f:t[`result]=`failed
q)update result:([]color:(sum f)#enlist"red")from `at where f
q)at
a b c d result
----------------------------------------
()!() ()!() ()!() ()!() ()!()
()!() ()!() ()!() ()!() (,`color)!,"red"
()!() ()!() ()!() ()!() ()!()
()!() ()!() ()!() ()!() ()!()
我们可以使用.h.htac
使用属性字典标记表格单元格。首先将表格单元格作为字符串:
q)string t cols t
"94" ,"8" "97" "52"
"66" "24" "60" "69"
,"8" "62" "95" "59"
"82" "47" "26" "93"
"success" "failed" "success" "success"
不要介意它们被翻转了。现在 at
中的字典也翻转了。
q)at cols t
()!() ()!() ()!() ()!()
()!() ()!() ()!() ()!()
()!() ()!() ()!() ()!()
()!() ()!() ()!() ()!()
()!() (,`color)!,"red" ()!() ()!()
我们可以将它们分别用作.h.htac
的第二个和第一个参数。 each-both adverb将遍历相应的行,但我们需要相应的单元格,因此 .h.htac''
在行内的单元格内进行迭代。
q).h.htac''[`td;at cols t;string t cols t]
"<td>94</td>" "<td>8</td>" "<td>97</td>" "<td>52..
"<td>66</td>" "<td>24</td>" "<td>60</td>" "<td>69..
"<td>8</td>" "<td>62</td>" "<td>95</td>" "<td>59..
"<td>82</td>" "<td>47</td>" "<td>26</td>" "<td>93..
"<td>success</td>" "<td color=\"red\">failed</td>" "<td>success</td>" "<td>su..
函数 markup
组装 HTML table
元素:
markup:{[t]
th:.h.htc[`tr;]raze .h.htc[`th;] each string cols t; / table head
at:flip (cols t)! (count each(cols t;t))#enlist ()!(); / empty attribute dictionaries
f:t[`result]=`failed;
at:update result:([]color:(sum f)#enlist"red")from at where f; / attributes for result failed
tr:.h.htc[`tr;]each raze each flip .h.htac''[`td;at cols t;string t cols t]; / table rows
.h.htc[`table;] .h.htc[`thead;th],.h.htc[`tbody;raze tr]
}
使用属性字典表 是一种强大的技术,可适用于各种突出显示或为客户端脚本提供 ID。
关于html - 如何在 html5 的表格中突出显示/更改颜色到特定单词?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46777588/
有没有一种方法可以“标记”对象的属性,使它们在反射中“突出”? 例如: class A { int aa, b; string s1, s2; public int AA
我是一名优秀的程序员,十分优秀!