- $.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.codesnippet.cn/detail/0708201513383.html
来源: http://www.codesnippet.cn/detail/0708201513383.html