Easyui DataGrid RowNumber Line number display problem

Source: Internet
Author: User

When your row data exceeds 9999 in the DataGrid, the row number RowNumber of the first column will not display all the numbers because the table contents are too long.
This Easyui cannot be adaptive so it needs to be modified, and here's a way to extend a method.

$.extend ($.fn.datagrid.methods, {fixrownumber: function (JQ) {        returnJq.each ( function () {            varPanel = $ ( This). DataGrid ("Getpanel");//Gets the number container for the last row and copies a copy of the            varClone = $ (". Datagrid-cell-rownumber", panel). Last (). Clone ();//Because in some browsers, it is not supported to get the width of hidden elements, so trickery a bitClone.css ({"Position":"Absolute", left:- +}). AppendTo ("Body");varwidth = clone.width ("Auto"). width ();//The default width is 25, so fix is only available when it is greater than 25            if(Width > -) {//Add 5 pixels and keep a little margin$(". Datagrid-header-rownumber,.datagrid-cell-rownumber", panel). Width (width +5);//After modifying the width, the container needs to be recalculated, so call resize$( This). DataGrid ("Resize");//Some cleanup workClone.remove (); Clone =NULL; }Else{//revert to default state$(". Datagrid-header-rownumber,.datagrid-cell-rownumber", panel). Removeattr ("Style");    }        }); }});

Add the above code to the Easyui source

Then add the Onloadsuccess event in your $ ("#dg"). DataGrid ()

$("#dg").datagrid({    function () {        $(this).datagrid("fixRownumber");    }});

Easyui DataGrid RowNumber Line number display problem

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.