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',
                    width: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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值