资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

jQueryEasyUIeditor扩展,使其支持combo多选下拉列表

   在使用EasyUI treeGrid的editor进行行编辑的时候需要使用到combo多选下拉列表,通过查询API和源码后发现它并不支持combo,于是决定自己扩展,自定义一个combo Editor;

成都创新互联公司是一家集网站建设,项城企业网站建设,项城品牌网站建设,网站定制,项城网站建设报价,网络营销,网络优化,项城网站推广为一体的创新建站企业,帮助传统企业提升企业形象加强企业竞争力。可充分满足这一群体相比中小企业更为丰富、高端、多元的互联网需求。同时我们时刻保持专业、时尚、前沿,时刻以成就客户成长自我,坚持不断学习、思考、沉淀、净化自己,让我们为更多的企业打造出实用型网站。

   通过查看源代码发现,定义一个editor,需要实现四个方法(init,getValue,setValue,resize)

jQuery EasyUI editor扩展,使其支持combo多选下拉列表

这里一般注意init,getValue和setValue这三个方法,需要注意的是,这里的setValue和getValue方法都是针对于editor的,是给editor设值和获取值的。

定义combo:

$.extend($.fn.datagrid.defaults.editors, {

   combo: {

       init: function(container, options){

           var input = $('').appendTo(container);

           input.combo(options);

           var html = "";

           html+='

';

           html+='

'+options.title+'
';

           for(var i=0;i

           html+=''+options.data[i].name+'
';

       }

       html+='

';

       $(html).appendTo($('#cc').combo('panel'));

       $('#sp input').click(function(){

           var _value="";

           var _text="";

           $("[name=lang]:input:checked").each(function(){

               _value+=$(this).val()+",";

               _text+=$(this).next("span").text()+",";

           });

           if(_value.length>0){

               _value=_value.substring(0,_value.length-1);

           }

           if(_text.length>0){

               _text=_text.substring(0,_text.length-1);

           }

               $('#cc').combo('setValue',_value).combo('setText', _text);

           });

           return input;

       },

       destroy: function(target){

           $(target).combo('destroy');

       },

       getValue: function(target){

       return $(target).combo('getValue');

       },

       setValue: function(target, value){

           $(target).combo('setValue', value);

       },

       resize: function(target, width){

           $(target).combo('resize',width);

       }

   }

});

使用:

jQuery EasyUI editor扩展,使其支持combo多选下拉列表

页面展示效果:

jQuery EasyUI editor扩展,使其支持combo多选下拉列表


名称栏目:jQueryEasyUIeditor扩展,使其支持combo多选下拉列表
链接分享:http://cdkjz.cn/article/gjgdcs.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

大客户专线   成都:13518219792   座机:028-86922220