/** * * Author 花米[ sjbwylbs@163.com ] * * * 使用方法: 1. 導入 var $ = require('jquery'); require("ligerui")($); * require('select2')($); var myselect = require('ligerSelect')($); * * 2. $.ligerDefaults.Grid.editors['myselect'] = myselect; * * 3.在grid定義中使用 * * editor : { type : 'myselect', width : '300px', .....其餘的select2的參數 } * * * */ define(function(require, exports, module) { return function($) { var myselect = { create: function (container, editParm) { var column = editParm.column; var p = column.editor; p.select2 = $('<select class="myselect" />'); container.append(p.select2); var $option = $("<option selected></option>").val(editParm.value).text(editParm.text); p.select2.select2(p).on('select2:select',function(e){ p.onSelect && p.onSelect(e); }).val(editParm.value).append($option).select2('open'); return p.select2; }, getText: function (el, editParm) { return $(el).find("option:selected").text(); }, getValue: function (el, editParm) { return $(el).val(); }, resize: function (el, width, height, editParm) { el.width(width).height(height); }, destroy: function (el) { $(el).off().select2('destroy'); } }; return myselect; } });