zoukankan      html  css  js  c++  java
  • datagrid中需要填写长文本,扩展的textarea

    $.extend($.fn.datagrid.defaults.editors, {
    textarea: {//textarea就是你要自定义editor的名称
        init: function(container, options){
            var me = this;
            var cur = $('<input id="inputID"/>');
             
            $('<div id="win"><textarea rows="9" cols="43" id="textareaID" class="datagrid-editable-input"></textarea></div>').appendTo($("body"));
            var editor = cur.appendTo(container);
            $(cur).focus(function (){
                if(!textareaWin){
     
                    $("#textareaID").val($("#inputID").val());
                     
                    textareaWin = $('#win').dialog({
                        title:'My Windows',
                        350,
                        height:220,
                        closable:false,
                        resizable:false,
                        closed: false,
                        collapsible:false,
                        maximizable:false,
                        minimizable:false,
                        modal:true,
                        buttons:[{
                            text:'保存',
                            iconCls:'icon-add',
                            handler:function(){
                                var textVal = $("#textareaID").val();
                                 
                                $("#inputID").val(textVal);
                                 
                                textareaWin.window('close');
                                textareaWin = undefined;
                            }
                        },{
                            iconCls:'icon-reject',
                            text:'取消',
                            handler:function(){
                                $.messager.confirm('【提示信息】', '是否确认退出编辑?',function(r){
                                    if (r){
                                        textareaWin.window('close');
                                        textareaWin = undefined;
                                    }
                                });                     
                                 
                            }
                        }]
                    });
                     
                    $("#textareaID").focus();
                }
            });
            console.log("init method invoke!");
            editor.enableEdit = false;
            return editor;
        },
        getValue: function(target){
            return $(target).val();
       },
        setValue: function(target, value){          
            $(target).val(value);
        },
        resize: function(target, width){
            console.log("resize method invoke!");     
        },
        destroy: function(target){
            console.log("destroy method invoke!");
            textareaWin = undefined;
        }
    }
    });

    引用地址:http://www.oschina.net/code/snippet_571282_34699

  • 相关阅读:
    利用GetInvalidFileNameChars()得到有效的文件名
    C# 下载远程http文件到本地
    CLR无法从COM 上下文*****转换为COM上下文*****,这种状态已持续60秒。
    Wpf UserControl使用 KeyBinding,失效问题
    C# windows服务知识集锦
    制作Windows服务和安装程序(C#版)
    C语言内存管理
    Python初学注意问题
    msp430学习笔记-USART
    msp430学习笔记-ADC12
  • 原文地址:https://www.cnblogs.com/hubing/p/4060939.html
Copyright © 2011-2022 走看看