miniui渲染方法汇总

论坛 期权论坛 脚本     
匿名技术用户   2020-12-27 03:47   11   0

设置不能选今天以后的日期

ondrawdate="onDrawDate"

function onDrawDate(e) {
            var date = e.date;
            var d = new Date();
            if (date.getTime() > d.getTime()) {
                e.allowSelect = false;
            }
        }

添加按钮

renderer="onActionRenderer"

 function onActionRenderer(e) {
             var returntime=e.row.returntime;
             var s ='';           
             if(returntime!=null){
               s = '<a class="mini-button" style="background-color: pink;" οnclick="remove()">删除</a> ';  
             }else{              
              s = '<a class="mini-button"   οnclick="returnbook()">还书</a> ';                  
             }
             return s;
         }

 function onActionRenderer(e) {
             var bookid=e.row.bookid;
             var s = '<a class="mini-button"iconCls="icon-add" οnclick="edit()">编辑</a> '
                     + '&nbsp;&nbsp;<a class="mini-button"iconCls="icon-remove" style="background-color: pink;"  οnclick="remove()">删除</a> '
                     + '&nbsp;&nbsp;<a class="mini-button"iconCls="icon-remove" style="background-color: yellow;"  οnclick="borrow()">借阅</a> '
                     + '&nbsp;&nbsp;<a class="mini-button"iconCls="icon-remove" style="background-color: orange;"  οnclick="detail()">详情</a> ';
                     
             return s;
         }

时间格式

function onBorrowtimeRender(e){
    var borrowtime = e.row.borrowtime;
    var borrowtimeFormat = mini.formatDate (new Date(borrowtime), "yyyy-MM-dd H:mm:ss" );
    return borrowtimeFormat;
   }
   
   function onReturntimeRender(e){
    var returntime = e.row.returntime;
    if(returntime != null){
     var returntimeFormat = mini.formatDate (new Date(returntime), "yyyy-MM-dd H:mm:ss" )
     return returntimeFormat;
    }else{
     return "";
    }
   }

清空输入框并刷新表格

function onResetClick(e) {
    var form = new mini.Form("#searchform");
    form.clear();
     grid.load();
   }

设置数字变色

function onRemainRender(e) {
    var remain =e.row.remain;
    if(remain<=10){
     e.cellStyle='font-weight:bold;color:red;';
    }
    return remain;
   }  

下拉框

var BookTypes = [
          { id: 0, text: '请选择' },
          { id: 1, text: '文学类' },
          { id: 2, text: '科技类'},
          { id: 3, text: '艺术类'},
          { id: 4, text: '教育类'},
          { id: 5, text: '其他'}];        
         function onBookTypeRenderer(e) {
             for (var i = 0, l = BookTypes.length; i < l; i++) {
                 var t = BookTypes[i];
                 if (t.id == e.value) return t.text;
             }
             return "";
         }

分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:7942463
帖子:1588486
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP