I am trying to use ag-grid-community instead of ag-grid, and I am running into problems.
The main problem is that I have a blank grid, instead of it showing data.
I followed this reccommendation: https://www.ag-grid.com/javascript-grid-npm/
But when I use import {Grid} from '@ag-grid-community/all-modules';
, I get the following error:
ERROR in ./src/customer.js
Module not found: Error: Can't resolve '@ag-grid-community/all-modules' in '/home/employees/rhys/aris1/src'
@ ./src/customer.js 19:0-54 861:30-34
@ ./src/app.js
@ ./src/login.js
@ ./src/main.js
@ ./node_modules/aurelia-webpack-plugin/runtime/empty-entry.js
@ multi aurelia-webpack-plugin/runtime/empty-entry aurelia-webpack-plugin/runtime/pal-loader-entry aurelia-bootstrapper
If I use import {Grid} from 'ag-grid-community';
, I get a blank grid.
I can print out the values and see the data that should be in the grid, and it is sized as though there is data, but it’s blank.
Here’s my html declaration of the grid:
<div id="phoneGrid" style="height: 800px;width: 800px" class="ag-theme-alpine">
</div>
Here’s my js code:
imports and includes:
import {Grid} from 'ag-grid-community';
import "ag-grid-community/dist/styles/ag-theme-balham.css";
import 'ag-grid-community/dist/styles/ag-grid.css';
import 'ag-grid-community/dist/styles/ag-theme-material.css';
grid initialization:
async initGrid()
{
// console.log('initgrid', this);
this.columnDefinitions = [
{
checkboxSelection: true,
},
{headerName: 'Name',
field: 'descr',
unSortIcon: true,
width: 100,
editable: true,
rowDrag: true,
valueGetter: function(params) {
//debugger;
console.log('descr', params.data.descr);
return params.data.descr;
},
valueSetter: function(params) {
if ( params.descr != params.newValue)
{
//debugger;
params.data.descr = params.newValue;
document.form.saveDbtr.disabled = false;
}
else
{
return params.data.descr;
}
return true;
},
//checkboxSelection: true,
},
{headerName: 'Phone/Fax/Email',
field: 'phone',
editable: true,
width: 180,
valueGetter: function(params) {
return params.data.phone;
},
valueSetter: function(params) {
if ( params.phone != params.newValue)
{
params.data.phone = params.newValue;
document.form.saveDbtr.disabled = false;
}
else
{
return params.data.phone;
}
return true;
}, },
{headerName: 'Type',
field: 'type',
editable: true,
width: 50,
valueGetter: function(params) {
return params.data.type;
},
valueSetter: function(params) {
if ( params.type != params.newValue)
{
params.data.type = params.newValue;
document.form.saveDbtr.disabled = false;
}
else
{
return params.data.type;
}
return true;
},
cellRenderer: this.phoneSelect,
},
{headerName: 'Status',
field: 'status',
editable: true,
width: 80,
valueGetter: function(params) {
return params.data.status;
},
valueSetter: function(params) {
if ( params.status != params.newValue)
{
params.data.status = params.newValue;
document.form.saveDbtr.disabled = false;
}
else
{
return params.data.status;
}
return true;
},
cellRenderer: this.phoneStatusSelect,
},
{field: 'debtor_id', hide: true},
{field: 'item_no', hide: true},
{field: 'time_stamp', hide: true},
{field: 'user_id_stamp', hide: true},
{field: 'source', hide: true},
{field: 'source_id', hide: true},
{field: 'archive', hide: true},
{field: 'group_id', hide: true},
{headerName: 'Contact Type',
field: 'contact_type',
editable: true,
width: 80,
cellRendererParams: { value: this.contactType } ,
valueGetter: function(params) {
return params.data.contact_type;
},
valueSetter: function(params) {
if ( params.contact_type != params.newValue)
{
params.data.contact_type = params.newValue;
document.form.saveDbtr.disabled = false;
}
else
{
return params.data.contact_type;
}
return true;
},
cellRenderer: this.contactTypeSelect},
];
this.gridOptions = {
context: {parentComponent: this},
columnDefs: this.columnDefinitions,
defaultColDef: {
width: 100,
sortable: true,
},
rowData: this.phone_list,
rowSelection: 'single',
rowDragManaged: true,
animateRows: true,
};
var eGridDiv = document.querySelector('#phoneGrid');
this.grid = new Grid(eGridDiv, this.gridOptions);
// console.log('new grid', eGridDiv);
this.gridOptions.api.setRowData(this.phone_list);
this.gridOptions.api.refreshCells();
// console.log('phone_list', this.phone_list);
}
This all started because I was trying to add drag/drop capability and sorting to the grid. I discovered that ag-grid is outdated, and so moved to install the new ag-grid-community via npm.
Thanks in advance.