I have been working on creating a spreadsheet using Angular, and I have managed to implement most of the basic features. However, I am facing a challenge with sorting data by a single column within my current data structure.
Here is the link to the Plnkr showcasing my work so far.
Do you believe that restructuring the data to have separate arrays for different columns would be a better approach, or is there a way to achieve sorting within the existing structure?
At the moment, the spreadsheet is dynamically generating properties for the scope object based on cell value changes.
Below is the code snippet responsible for generating and calculating cell values:
process = function (exp) {
return exp.replace(/[A-Z]\d+/g, function (ref) {
return 'result("' + ref + '")';
})
}
$scope.result = function (cell) {
if ($scope.cells[cell]) {
if (stringStartsWith($scope.cells[cell], "=")) {
var val = $scope.cells[cell].substring(1);
return $parse(process(val))($scope);
}
else {
return $scope.cells[cell];
}
}
else {
return $scope.cells[cell];
}
};