【问题标题】:Angular UI-Grid: In a cell template, how to access the value from a different field/cellAngular UI-Grid:在单元格模板中,如何从不同的字段/单元格访问值
【发布时间】:2015-09-05 13:04:56
【问题描述】:

我一直在尝试使用 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,在name字段中,我需要使用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 值之外,该表呈现良好。我在超链接(name 列 内)中获得的值是连续的:1、2 和 3,而不是 数据数组中定义的 10、12 和 20 > 但是,ID 列中显示的 id 值是我所期望的:10、12 和 20。我想知道您将如何访问 id name字段中的字段值,为什么name单元格中的id是连续的?

【问题讨论】:

    标签: javascript angularjs angular-ui-grid


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-09-16
      • 2019-03-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-01-14
      • 2021-06-01
      • 2017-07-01
      相关资源
      最近更新 更多