I am currently utilizing AngularJS ng-grid and endeavoring to accomplish the following tasks: 1. Adjust column width dynamically based on the content within each column. 2. Automatically resize the last column to fill the remaining space when hiding columns (For instance, if there are 8 columns each with a width of 100 and the total ng-grid width is 800...if 4 columns are hidden, the last column should automatically expand to a width of 500).
At present, I have implemented code for task 1 but it's not functioning as expected (columns are not resizing according to the content). Therefore, I'm seeking assistance in identifying any missing elements and guidance on how to achieve task 2. Thank you
var app = angular.module('myNGridApp', ['ngGrid']);
app.controller('myNGCtrl', function($scope) {
$scope.myData = [{id: "#4", di: 50, taskstatus: "Lorem Ipsum text", notes: "Lorem Ipsum text", datecreated: "02/04/2014"},
{id: "#4", di: 50, taskstatus: "Lorem Ipsum text", notes: "Lorem Ipsum text", datecreated: "02/04/2014"},
{id: "#4", di: 50, taskstatus: "Lorem Ipsum text", notes: "Lorem Ipsum text", datecreated: "02/04/2014"},
{id: "#4", di: 50, taskstatus: "Lorem Ipsum text", notes: "Lorem Ipsum text Lorem Ipsum text Lorem Ipsum text Lorem Ipsum text Lorem Ipsum text Lorem Ipsum text Lorem Ipsum text Lorem Ipsum text Lorem Ipsum text Lorem Ipsum text Lorem Ipsum text Lorem Ipsum text Lorem Ipsum text Lorem Ipsum text Lorem Ipsum text Lorem Ipsum text Lorem Ipsum text Lorem Ipsum text Lorem Ipsum text Lorem Ipsum text Lorem Ipsum text Lorem Ipsum text Lorem Ipsum text Lorem Ipsum text Lorem Ipsum text ", datecreated: "02/04/2014"},
{id: "#4", di: 50, taskstatus: "Lorem Ipsum text", notes: "Lorem Ipsum text", datecreated: "02/04/2014"}];
$scope.columnDefs= [{ field: 'id', displayName: 'ID', resizable: true, minWidth: 100, width: 'auto' },
{ field: 'di', displayName: 'DI', resizable: true, minWidth: 100, width: 'auto' },
{ field: 'taskstatus', displayName: 'Task Status', resizable: true, minWidth: 200, width: 'auto' },
{ field: 'notes', displayName: 'Notes', resizable: true, minWidth: 400, width: 'auto' },
{ field: 'datecreated', displayName: 'Date Created', resizable: true, minWidth: 200, width: 'auto' }];
$scope.gridOptions = {
data: 'myData',
columnDefs: 'columnDefs',
footerVisible: true,
enableColumnResize: true,
filterOptions: {filterText: '', useExternalFilter: false},
showColumnMenu: true,
showFilter: true,
plugins: [new ngGridFlexibleHeightPlugin()],
virtualizationThreshold: 10,
};
});