jqgrid ellipsis

后端 未结 2 1341
清酒与你
清酒与你 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:10

    You can solve the problem using the following CSS

    <style type="text/css">
        .ui-jqgrid tr.jqgrow td { text-overflow: ellipsis;-o-text-overflow: ellipsis; }
    </style>
    

    In the case you will have the results like displayed below:

    enter image description here

    (see here live)

    In some other situations another CSS style would be better:

    <style type="text/css">
        .ui-jqgrid tr.jqgrow td {
            white-space: normal !important;
            height:auto;
            vertical-align:middle;
            padding-top:3px;
            padding-bottom:3px
        }
    </style>
    

    In the case the results are the following:

    enter image description here

    (see here live).

    Both above settings are my common settings which I use frequently depended on the customers requirements.

    0 讨论(0)
  • 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 });
    
    0 讨论(0)
提交回复
热议问题