Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular-UI grid : adding custom field in columnDefs and access it from header template

I want to add some custom field in columnDefs and want to access it from header template. As an example , i want a field let say showFile

$scope.gridOptions.columnDefs = [
       {                
                name: 'ServiceID',
                displayName: 'Service',
                showFile: some data
      }]

and want to access showFile inside header template ...

<div class="ui-grid-top-panel"  style="text-align: center">
      {{ want to access 'showFile' }}
</div>

What's the best possible way to do this. As i have tried it using custom method as

<div class="ui-grid-top-panel"  style="text-align: center">
{{grid.appScope.letter()}}
</div>

(plnkr link http://plnkr.co/edit/ZW43LsiLY7GdnX6XEOgG?p=preview , http://plnkr.co/edit/3E8HTz4Z2daGqRh1WHtx?p=preview) but , the function (grid.appScope.letter()) is being called for infinite number of times . I have raised the issue but didn't got any reply .. https://github.com/angular-ui/ui-grid/issues/4250 , https://github.com/angular-ui/ui-grid/issues/4314. Can anyone please suggest the best possible way to achieve the above mentioned task.

like image 467
surya singh Avatar asked Sep 22 '15 16:09

surya singh


1 Answers

Try using renderIndex. This will give you the column's index.

{{grid.appScope.gridOptions.columnDefs[renderIndex].customField}}
like image 107
Mr. Robot Jr. Avatar answered Sep 22 '22 19:09

Mr. Robot Jr.