EasyUI Forum

General Category => General Discussion => Topic started by: catpaw on April 16, 2015, 01:46:59 PM



Title: how I do this
Post by: catpaw on April 16, 2015, 01:46:59 PM
hello!!

in the demo section http://jeasyui.com/demo/main/index.php?plugin=DataGrid

the Column Group example says:

to declare table like this:

Code:
<table class="easyui-datagrid" title="Column Group" style="width:700px;height:250px"
            data-options="rownumbers:true,singleSelect:true,url:'datagrid_data1.json',method:'get'">
        <thead>
            <tr>
                <th data-options="field:'itemid',width:80" rowspan="2">Item ID</th>
                <th data-options="field:'productid',width:100" rowspan="2">Product</th>
                <th colspan="4">Item Details</th>
            </tr>
            <tr>
                <th data-options="field:'listprice',width:80,align:'right'">List Price</th>
                <th data-options="field:'unitcost',width:80,align:'right'">Unit Cost</th>
                <th data-options="field:'attr1',width:240">Attribute</th>
                <th data-options="field:'status',width:60,align:'center'">Status</th>
            </tr>
        </thead>
    </table>

but I need do it on this way:

Code:
$('#dg').datagrid({
    url:'datagrid_data.json',
    columns:[[
        {field:'code',title:'Code',width:100},
        {field:'name',title:'Name',width:100},
        {field:'price',title:'Price',width:100,align:'right'}
    ]]
});

how can I write the code, to agroup the columns??

thank you


Title: Re: how I do this
Post by: stworthy on April 16, 2015, 05:46:45 PM
Please try this:
Code:
$('#dg').datagrid({
    columns:[[
        {field:'itemid',title:'Item ID',width:80,rowspan:2},
        {field:'productid',title:'Product',width:100,rowspan:2},
        {title:'Item Details',colspan:3}
    ],[
        {field:'code',title:'Code',width:100},
        {field:'name',title:'Name',width:100},
        {field:'price',title:'Price',width:100,align:'right'}
    ]]

})


Title: Re: how I do this
Post by: catpaw on April 16, 2015, 06:11:50 PM
thaks stworthy that works

I imagine that data should go with Same Structure, right?


Title: Re: how I do this
Post by: vencelylalas on April 24, 2015, 10:53:32 PM
yes it do works..
thanks for sharing such good source of codes for us..