Skip to content

Instantly share code, notes, and snippets.

@krujos
Created November 8, 2013 15:57
Show Gist options
  • Save krujos/7373160 to your computer and use it in GitHub Desktop.
Save krujos/7373160 to your computer and use it in GitHub Desktop.
ngGrid + angular dynamic cell text based off row value. I had to pad the number of rows in a ngGrid to achieve some consistency in our UI. That meant that where I was using cell templates to create links for action on a row I had to stop inserting text when we had an empty row. In order to do this I shoved an angular directive that calls a scope…
$scope.getCellText = function(key) {
if ( key ) {
return "Do stuff";
}
};
$scope.theData = {};
$scope.theGrid = {
data: 'theData',
columnDefs:
[
{
field: 'doesItHaveAValue',
cellTemplate: '<div class="ngCellText" ng-class="col.colIndex()" ng-click="some_fucntion(' +
'row.getProperty(col.field))"><a href="">{{getCellText(row.getProperty("doesItHaveAValue"))}}</a></div>',
width: 80
},
{field:'F2', width: 150},
{field:'F3', width: 100},
]
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment