如何在datagrid 的field单元格中加入一个链接,如何根据内容来替换单元格的内容?
这些功能都可以通过datagrid的formatter实现,比如如果要在一个单元格中加入一个链接,可以这样写
1: {
2: field: "xx",
3: formatter: function(value,row,index) {
4: return "<a href="#">test</a>"
5: }
6: }
如果想根据value的值不同来变换单元格内容,可以这样写
1: {
2: field: "test",
3: formatter: function(value,row,index) {
4: if (value == 1) {
5: return "right"
6: }else{
7: return "wrong"
8: }
9: }
10: }
其中value就是当前单元格的内容,row是整行的数据,index是行号.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }
来源:https://www.cnblogs.com/popping57/p/3311076.html