将超链接文本添加到特定行的ui-grid中



我有配置。json文件中,我定义了columnDefs。我想添加超链接文本到名称字段和重定向到页的信息,关于这一行。我尝试了一些例子,但没有成功。

json

    "columnDefs":[
      {
        "name": "name"
      },
      {
        "name": "object_type_s"
      }
   ........
    ]
控制器

$scope.gridOptions = {
  columndDefs: config.columnDefs,
  ......

}

如果我把cellTemplate像这样放在配置文件中

{
"name": "name",
 "cellTemplate": "<a href="#">"
},

这将在我的网格中的所有行中添加超链接。例如,我想只在

的行中添加超链接

scope.gridOptions.data美元。object_type == "SOMETHING"

当你点击一个名字时,它会带你进入下一页

 $scope.gridOptions = {
            paginationPageSizes : [ 25, 50, 75 ],
            paginationPageSize : 25,
            enableColumnResizing : true,
            enableSorting : true,
            enableRowSelection : true,
            enableSelectAll : true,
            enableRowHeaderSelection: true,
            selectionRowHeaderWidth : 35,
            rowHeight : 35,
        showGridFooter : true,

行模板用于获取ui-grid上的选定行

        rowTemplate : rowTemplate(),
        columnDefs : [
        {
        field : 'id',
        name : 'id',
        width: 200,
        },
        {   
            field : 'name',
            name  : 'name',
            width : 120,
            sort  : {
                priority : 0,
            },
            cellTemplate:'<div >' + '<a href="test.html">'+ '</a>' + '</div>',
        }
        } ],
          onRegisterApi: function(gridApi){
              $scope.gridApi = gridApi;
        }
    };

它得到一行,当我们选择一个记录

function rowTemplate() {
    return '<div ng-click="grid.appScope.rowDblClick(row);">' + ' <div ng-repeat="(colRenderIndex, col) in colContainer.renderedColumns track by col.colDef.name" class="ui-grid-cell"  ui-grid-cell></div>' + '</div>';
}

单击一行时,使用

方法获得一行
$scope.rowDblClick = function(row) {
    console.log('The selected object id is : ', row.entity.id);
    console.log('The selected object nameis : ', row.entity.name);
};

最新更新