ag-grid设置表格的行高和列的宽,表头的高度。
var gridOptions = {
rowHeight :30, //设置行高为30px,默认情况下是25px ******************
columnDefs: columnDefs,
rowData: data,
rowSelection: 'multiple',
rowMultiSelectWithClick: true,
suppressCellSelection: true
};
var gridOptions = {
rowHeight :30, //设置行高为30px,默认情况下是25px
columnDefs: columnDefs,
rowData: data,
rowSelection: 'multiple',
rowMultiSelectWithClick: true,
suppressCellSelection: true
};
//与列对应的数据
var data = [
{ id: 1, name: '张三', sex: '男', age: 100, 'sr': 1918 },
{ id: 2, name: '李四', sex: '女', age: 5, 'sr': 2000 },
{ id: 10, name: 'itxst.com', sex: '男', age: 35, 'sr': 2018 }
];
//设置单行选中
var gridOptions = {
rowHeight :30,
columnDefs: columnDefs,
rowData: data
};
//表格对象
var ag;
document.addEventListener("DOMContentLoaded", function () {
var eGridDiv = document.querySelector('#myGrid');
ag= new agGrid.Grid(eGridDiv, gridOptions);
});
//动态设置行高 重新设置为100px
function setHeight()
{
ag.gridOptions.rowHeight=100;
ag.gridOptions.api.resetRowHeights();
}
//设置列宽
var columnDefs = [
{
headerName: '姓名', field: 'name', filter: 'agTextColumnFilter',
'pinned': 'left',
width: 100, //把姓名列设置为100px ******************
},
{ headerName: '性别', field: 'sex' },
{ headerName: '年龄', field: 'age', filter: 'agNumberColumnFilter' },
{ headerName: '生日', field: 'sr', filter: 'agNumberColumnFilter' }
];
//设置表头的高度
var gridOptions = {
headerHeight:60, //设置表头的高度 ******************
rowHeight: 30,
columnDefs: columnDefs,
rowData: data,
rowSelection: 'multiple',
rowMultiSelectWithClick: true,
suppressCellSelection: true
};