EasyUi 表格自適應寬度


第一次接觸EasyUi想要實現表格寬度自適應,網上找了好多文章,都沒有實現,有網友實現了可是自己看不懂。可能是太簡單高手都懶得分享,現在把自己的理解和實現記錄一下,希望可以幫到向自己一樣的菜鳥,步驟如下:

第一步,把table標簽的屬性“fitColumns”設置為“true”

第二步,經過第一步的設置后,此時給標題的td設置width屬性,width的值此時設置為數字代表的就是寬度按百分比來設置,例如width:10,表示寬度為10%

代碼如下:

<table class="easyui-datagrid" style="width:100%;"
            data-options="singleSelect:true,collapsible:true,url:'demo/datagrid/datagrid_data1.json',method:'get',fitColumns:true">
        <thead>
            <tr>
                <th data-options="field:'itemid',width:10">Item ID</th>
                <th data-options="field:'productid',width:20">Product</th>
                <th data-options="field:'listprice',width:10,align:'right'">List Price</th>
                <th data-options="field:'unitcost',width:10,align:'right'">Unit Cost</th>
                <th data-options="field:'attr1',width:40">Attribute</th>
                <th data-options="field:'status',width:10,align:'center'">Status</th>
            </tr>
        </thead>
    </table>

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM