gpt4 book ai didi

javascript - Angular UI-Grid : In a cell template, 如何从不同的字段/单元格访问值

转载 作者:搜寻专家 更新时间:2023-11-01 04:15:41 24 4
gpt4 key购买 nike

我一直在尝试使用 Angular UI-Grid 插件来呈现数据表,并且我有以下示例数据:

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"},
];

下面是 gridOptions 的 columnDefs,在名称字段中,我需要使用 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}
];

row.entity.id 值外,表格呈现良好。我在超链接(名称列内)中获得的值是连续的:1、2 和 3,而不是 数据数组 中定义的 10、12 和 20 >,但是,ID 列中显示的 id 值正是我所期望的:10、12 和 20。我想知道您将如何访问 id name字段中的字段值,为什么name单元格中的id是连续的?

最佳答案

您不需要在 ui-sref 中使用大括号,因为您已经在 J​​S 表达式中。试试这个:

ui-sref="main.placeDetail({placeId: row.entity.id })"

关于javascript - Angular UI-Grid : In a cell template, 如何从不同的字段/单元格访问值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30939978/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com