ui-grid icon indicating copy to clipboard operation
ui-grid copied to clipboard

Empty row always at bottom of grid

Open alexvance89 opened this issue 11 years ago • 1 comments

How would it be possible to keep an empty row always at the bottom? I've been looking through the API, but i don't really see anything that could support this as of now. Essentially what I'm looking for is being able to have an empty row at the bottom that will allow a user to type into it and then it will automatically create a new row after that one has been modified (even if it's only 1 cell). Also, is there a way to keep the tabbing within the grid? If i reach the end of the grid, it should hopefully go back to the top left most cell.

alexvance89 avatar Aug 11 '15 13:08 alexvance89

I have a function that checks wether the last object in the data Array of the grid have a custom property.

_this.IsLastRowEmpty = function(objUIGrid) {
    var arrayData = null;
    var retValue = false;
    arrayData = objUIGrid.data;
    retValue = Object.keys(arrayData[arrayData.length - 1]).length === 1 ? true : false;
    return retValue;
 };

I use this function in the following Event:

 gridApi.edit.on.beginCellEdit($scope, function (rowEntity, colDef) {
        if (!IsLastRowEmpty($scope.gridOrderPos)) {
            $scope.gridOrderPos.data.push({});
        };
    });

When the last data object is not empty i simply push a empty object to the data Array.

JZehet avatar Nov 05 '15 15:11 JZehet