javascript - Angular UI-Grid: In a cell template, how to access the value from a different field/cell -


i've been trying use angular ui-grid plugin render data tables, , have following example data:

var data = [ {"id" : 10, "name" : "name 1", "city" : "san francisco"}, {"id" : 12, "name" : "name 2", "city" : "san diego"}, {"id" : 20, "name" : "name 3", "city" : "santa barbara"}, ]; 

below columndefs gridoptions, in name field, need create hyperlink using ui-sref

$scope.gridoptions.columndefs = [ {field: 'id', displayname: 'id'}, {field: 'name', celltemplate: '<div class="ui-grid-cell-contents tooltip-uigrid" title="{{col_field}}">' +                        '<a ui-sref="main.placedetail{{placeid: \'{{row.entity.id}}\' }}">{{col_field custom_filters}}</a></div>' }, {field: 'city', enablesorting: true} ]; 

the table rendered fine except row.entity.id value. values in hyperlinks (inside name column) sequential: 1, 2, , 3, instead of 10, 12, , 20 defined in data array, however, id values displayed in id column expecting: 10, 12, , 20. wonder how access id field value inside name field, , why id in name cell sequential?

you shouldn't need use curly braces in ui-sref you're in js expression. try this:

ui-sref="main.placedetail({placeid: row.entity.id })"


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -