宇筱博客

  • 解决办法
  • 学无止境
  • 记录时光
  • 百宝箱
宇筱博客
点滴记忆,汇聚成海。
  1. 首页
  2. 解决办法
  3. 正文

easyui中propertygrid实现密码显示效果

2017年1月8日 526点热度 0人点赞 0条评论

实现一个密码显示效果(非明文显示)

效果如下图所示,输入密码后鼠标点击其他地方,显示圆点代替









实现代码如下:



js扩展代码

(function($){
    /**
     * datagrid扩展
     */
    $.extend($.fn.datagrid.defaults.editors, {
        password: {
            init: function(container, options){
                return $('<input type="password" class="datagrid-editable-input" />').appendTo(container);
            },
            destroy: function(target){
                $(target).remove();
            },
            getValue: function(target){
                return $(target).val();
            },
            setValue: function(target, value){
                $(target).val(value);
            },
            resize: function(target, width){
                $(target)._outerWidth(width);
            }
        }
    });
})(jQuery);

初始化

 columns = [[
    {field: 'name', title: '名称', width: 80, sortable: true},
    {field: 'value', title: '参数', width: 200, sortable: false, formatter:function(value, arr){
        var editor = '';
        if(typeof arr.editor == 'object'){
            editor = arr.editor.type;
        }else{
            editor = arr.editor;
        }
        switch(editor){
            case 'password':
                return value.replace(/./g, '●');
                break;
            default:
                return value;
        }
    }}
]];

原文链接:http://www.thinkphp.cn/code/1516.html

标签: 暂无
最后更新:2017年1月8日

小渔民

这个人很懒,什么都没留下

点赞
< 上一篇
下一篇 >

文章评论

razz evil exclaim smile redface biggrin eek confused idea lol mad twisted rolleyes wink cool arrow neutral cry mrgreen drooling persevering
取消回复

COPYRIGHT © 2025 宇筱博客. ALL RIGHTS RESERVED.

Theme Kratos Made By Seaton Jiang

豫ICP备15017825号-2