首页 > 代码库 > datagrid中需要填写长文本,扩展的textarea

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

datagrid中需要填写长文本,扩展的textarea