我有以下json数据:
[
{"total_wt_arr_slp_buy":"-1.1411","total_wt_arr_last_slp_sell":"0.1308","total_exec_qty_buy":"1333409","total_ord_qty_sell":"1999840","total_wt_buy":"0.41","total_exec_qty_sell":"1859730","total_wt_ivwap_slp_sell":"-0.7283","total_wt_arr_last_slp_buy":"0.9204","total_wt_sell":"0.59","total_exec_val_sell":"106934063.00","total_wt_ivwap_slp_buy":"0.2858","total_exec_val_buy":"73297184.00","total_ord_qty_buy":"1456485","total_num_ords_sell":"2231","total_num_ords_buy":"1986","total_wt_arr_slp_sell":"-1.3096"}]
我正在使用ag-grid以下列方式显示此json数据:
var columnDefs = [
{headerName: "Orders", field: "total_num_ords_buy", width: 150, unSortIcon: true},
{headerName: "Order Qty", field: "total_ord_qty_buy", width: 150, unSortIcon: true},
];
var gridOptions = {
columnDefs: columnDefs,
rowData: null,
enableSorting: true,
enableFilter: true,
suppressContextMenu: true,
suppressMenuMainPanel: true,
suppressMenuColumnPanel: true
};
document.addEventListener('DOMContentLoaded', function() {
var gridDiv = document.querySelector('#myGrid');
new agGrid.Grid(gridDiv, gridOptions);
// do http request to get our sample data - not using any framework to keep the example self contained.
// you will probably use a framework like JQuery, Angular or something else to do your HTTP calls.
var httpRequest = new XMLHttpRequest();
httpRequest.open('GET', '../dist/output3.json');
httpRequest.send();
httpRequest.onreadystatechange = function() {
if (httpRequest.readyState == 4 && httpRequest.status == 200) {
var httpResult = JSON.parse(httpRequest.responseText);
function isNumeric(n) {
return !isNaN(parseFloat(n)) && isFinite(n);
}
var parsedData = httpResult.products.map(function(obj) {
return Object.keys(obj).reduce(function(memo, key) {
var value = obj[key];
memo[key] = isNumeric(value) ? Number(value) : value;
return memo;
}, {})
})
console.log(parsedData);
gridOptions.api.setRowData(parsedData);
}
};
});
我希望在第二行的total_num_ords_sell
Orders
下显示headerName
,但是当我{headerName: "Orders", field: "total_num_ords_sell", width: 150, unSortIcon: true},
时,它也会为它创建一个单独的列。我该怎么做?