jqgrid ellipsis

后端 未结 2 1365
清酒与你
清酒与你 2021-01-06 12:43

In jqGrid, is there a native way to show \"...\" at the end of a column if it\'s text did not fit and was truncated?

I see that there is a ui-ellipsis class but I\'m

2条回答
  •  感动是毒
    2021-01-06 13:22

    fit text plugin:
    
     (function($) {
            $.fn.fitText = function(options) {
                options = $.extend({
                    width: 0,
                    height: 0
                }, options);
    
                $(this).each(function() {
                    var elem = $(this);
                    if (options.height > 0) {
                        while (elem.height() > options.height) {
                            elem.text(elem.text().substring(0, (elem.text().length - 4)) + "...");
                        }
                    }
                    if (options.width > 0) {
                        while (elem.width() > options.width) {
                            elem.text(elem.text().substring(0, (elem.text().length - 4)) + "...");
                        }
                    }
                });
            }
        })(jQuery);
    
    
    calling the function:
    
        $('.ADHrefUserName').fitText({ width: 200, height: 25 });
    

提交回复
热议问题