zoukankan      html  css  js  c++  java
  • easyui datagrid 自定义editor并根据实际情况(自定义options)判断返回多样的html控件

    在添加的时候全部列都变成编辑状态,编辑的时候某些列不变成编辑状态,解决方法
    
    1 自定义editor
    
    
    $.extend($.fn.datagrid.defaults.editors, {
        Uploadfile: {//Uploadfile就是你要自定义editor的名称   
            init: function (container, options) {
                 /////通过options传参数
                var status = $("#hidMode").val();
                if (status == 'edit') {
                    var input = $("<a href='#' style='cursor:pointer;' value='" + options.url + "'  onclick='ShowFile(this.value)'  ></a>")
                               .appendTo(container);
                }
                else {
                    var input = $("<input type='file'  id='Uploadfile'  name='Uploadfile'/>")
                              .appendTo(container);
                }
                return input;
            },
            getValue: function (target) {
    
                return $(target).val();
            },
            setValue: function (target, value) {
                var status = $("#hidMode").val();
                if (status == 'edit') {
                    $(target).val($(target).val() + value);
                    $(target).text(value);
                }
                else {
                    $(target).val(value);
                }
            },
            resize: function (target, width) {
                var input = $(target);
                if ($.boxModel == true) {
                    input.width(80);
                } else {
                    input.width(width);
                }
            }
        }
    });
    
    
    dataGrid 使用 自定义editors
    
    {
    field: '文件名称', title: '文件名称',  getWidth(0.1), align: 'left', sortable: true,
     editor: {
     type: 'Uploadfile', 
    options: { status: '', url: '/UploadFiles/MaterialFile/'}
             }
    }
    ///options里面不可以使用 value,传输的参数是文本
  • 相关阅读:
    C++模板&泛型编程
    C++继承
    测试pc大、小端
    C语言标准定义的32个关键字
    *塔,菱形
    练习小题目
    c一些关键字
    uvaoj 489
    uvaoj1339
    hdu1969Pie(根据体积二分,分馅饼)
  • 原文地址:https://www.cnblogs.com/hbhzz/p/4075666.html
Copyright © 2011-2022 走看看