Angular UI-网格:在单元格模板中,如何从不同的field/cell访问值
Angular UI-Grid: In a cell template, how to access the value from a different field/cell
我一直在尝试使用 Angular UI-Grid 插件来呈现数据 tables,我有以下示例数据:
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 值外,table 渲染良好。我在超链接中获得的值(在 名称列 内)是连续的:1、2 和 3,而不是 中定义的 10、12 和 20数据数组 ,但是,id 列中显示的 ID 值正是我所期望的:10、12 和 20 . 我想知道你将如何访问 name 字段中的 id 字段值,为什么 id 在 name 单元格中是连续的?
您不需要在 ui-sref
中使用花括号,因为您已经在 JS 表达式中了。试试这个:
ui-sref="main.placeDetail({placeId: row.entity.id })"
我一直在尝试使用 Angular UI-Grid 插件来呈现数据 tables,我有以下示例数据:
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 值外,table 渲染良好。我在超链接中获得的值(在 名称列 内)是连续的:1、2 和 3,而不是 中定义的 10、12 和 20数据数组 ,但是,id 列中显示的 ID 值正是我所期望的:10、12 和 20 . 我想知道你将如何访问 name 字段中的 id 字段值,为什么 id 在 name 单元格中是连续的?
您不需要在 ui-sref
中使用花括号,因为您已经在 JS 表达式中了。试试这个:
ui-sref="main.placeDetail({placeId: row.entity.id })"