EasyUI Forum
May 17, 2024, 07:22:35 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: datagrid column fit to available width  (Read 14133 times)
devnull
Sr. Member
****
Posts: 431


View Profile
« on: May 27, 2014, 06:30:34 AM »

Is it possible to make the final column in a datagrid automatically expand it's width to fill the entire available width ?
Logged

-- Licensed User --
jarry
Administrator
Hero Member
*****
Posts: 2264


View Profile Email
« Reply #1 on: May 27, 2014, 07:03:28 AM »

First of all, set the 'fitColumns' property to true for the datagrid, and then set the 'fixed:true' for all the columns except the final column. The code looks like this:
Code:
<table id="dg" class="easyui-datagrid" title="Basic DataGrid" style="width:700px;height:250px"
        data-options="
        fitColumns:true,
        singleSelect:true,url:'datagrid_data1.json',method:'get'">
    <thead>
        <tr>
            <th data-options="field:'itemid',width:80,fixed:true">Item ID</th>
            <th data-options="field:'productid',width:60,fixed:true">Product</th>
            <th data-options="field:'listprice',width:80,align:'right',fixed:true">List Price</th>
            <th data-options="field:'unitcost',width:80,align:'right',fixed:true">Unit Cost</th>
            <th data-options="field:'attr1',width:150">Attribute</th>
        </tr>
    </thead>
</table>
Logged
morib
Newbie
*
Posts: 14


View Profile
« Reply #2 on: May 29, 2014, 04:07:41 PM »

I have a very similar use case.  In my case, the width of each columns is not known.  Once the data is loaded I perform and Autofit method on all columns.  What I would like to do is to autofit all columns except the last one and have that one take all remaining space to fill the width of the datagrid (and not have the "empty" section on the datagrid on the right.  Is this possible?
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!