EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: wymak on July 05, 2018, 01:51:19 AM



Title: retrieve all values from one particular column in datagrid
Post by: wymak on July 05, 2018, 01:51:19 AM
I have a datagrid with 2 columns (id and temperature) , something like below:   

<table id="dg" title="View Log" class="easyui-datagrid" style="width:auto;height:auto;"
            url="getlog.php" >
        <thead>
            <tr>
                <th field="id">ID</th>
                <th field="temperature">Temperature</th>
            </tr>
        </thead>
</table>

How can I retrieve the array of temperature values from the datagrid,
arr  = $('#dg').datagrid('options').columns['temperature']   does not work.

thanks,
Mak


Title: Re: retrieve all values from one particular column in datagrid
Post by: stworthy on July 05, 2018, 03:39:10 AM
Call the 'getRows' method to get all the rows and convert to the array you want.
Code:
var rows = $('#dg').datagrid('getRows');
var arr = $.map(rows, function(row){return row. temperature});
console.log(arr);