esayui treegird no wrap 不起作用 文字过多不能自动换行

我们不生产代码,我们至少代码的搬运工.

社区issue  [SOLVED] Treegrid nowrap (jeasyui.com) 

https://www.jeasyui.com/forum/index.php?topic=6468.0

解决方案出处 :http://code.reloado.com/abucaz/edit#preview

 

 

 

 

 

现象:

 

 

 

社区给出的拓展方法

 1 (function($){
 2     var fixColumnSize = $.fn.datagrid.methods.fixColumnSize;
 3     $.extend($.fn.datagrid.methods, {
 4         fixColumnSize: function(jq, field){
 5             return jq.each(function(){
 6                 fixColumnSize($(this), field);
 7                 if ($(this).data('treegrid')){
 8                     var opts = $(this).treegrid('options');
 9                     var field = opts.treeField;
10                     $(this).treegrid('getPanel').find('td[field="'+field+'"] .datagrid-cell').each(function(){
11                         var width1 = $(this).width() - ($(this).children('span').length-1)*16;
12                         $(this).find('.tree-title').css({
13                             whiteSpace: 'normal',
14                             height: 'auto'
15                         }).width(width1);
16                     });
17                     $(this).treegrid('fixRowHeight');
18 
19                 }
20             });
21         }
22     });
23 })(jQuery);

使用拓展

$(function(){
            $('#tg').treegrid({
                data: data,
                idField: 'id',
                treeField: 'name',
                nowrap: true,//注意这里是true
                onLoadSuccess: function(){
                  $(this).treegrid('fixColumnSize','name');//fixColumnSize 的参数是 col.field
} }) })

最后效果:

 

posted @ 2021-03-10 11:07  天朝95  阅读(112)  评论(0编辑  收藏  举报