转载自:点击打开链接
- function formatProPic(val, row) {
- return "<img width=80 height=110 src='../" + val + "'>";
- }
- function formatStatus(val, row) {
- if (row.status == 1)
- return "<div style='color:red;'>已上架</div>";
- else
- return "<div style='color:gray;'>未上架</div>";
- }
- <th field="path" width="100" align="center" formatter="formatProPic">图片</th>
- <th field="status" width="55" align="center"
- formatter="formatStatus">上架状态
- </th>
- ---------------------------------------------------------------------------
- function formatHref1(val, row) {
- return "<a href='${pageContext.request.contextPath}/article.html?id=" + row.id + "' target='_blank'>查看详情</a>";
- }
- <th field="content" width="70" align="center"
- formatter="formatHref1">操作
- formatDateTime : function(val,row){
- var now = new Date(val);
- return now.format("yyyy-MM-dd hh:mm:ss");
- },
- // 格式化连接
- formatUrl : function(val,row){
- if(val){
- return "<a href='"+val+"' target='_blank'>查看</a>";
- }
- return "";
- },
- // 格式化价格
- formatPrice : function(val,row){
- return (val/1000).toFixed(2);
- },
- // 格式化商品的状态
- formatItemStatus : function formatStatus(val,row){
- if (val == 1){
- return '正常';
- } else if(val == 2){
- return '<span style="color:red;">下架</span>';
- } else {
- return '未知';
- }
- },