一个属性添加到NG-网格列 [英] Add a property to ng-grid column

查看:133
本文介绍了一个属性添加到NG-网格列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用NG-格,我想补充我自己的提示,使用标题单元格模板。要做到这一点,我想创建一个名为提示,例如列属性。试过了,它不会在山坳的属性显示。你觉得给我们的功能是什么。否则,我创建在每种情况下一个新的模板?

请参阅plunkr: http://plnkr.co/edit/lSf4XK?p= preVIEW

理想情况下,gridOptions将包含这样的columnDefs:

  columnDefs:
    {场:'complex.name,显示名:名称,headerCellTemplate:header_template2.html},
    {场:'complex.active',
    DIMENSION1:测试,
    显示名:进行中,
    headerCellTemplate:header_template.html',
    cellTemplate:'checkBoxTemplate.html'}]

DIMENSION1 属性将在像这样的模板访问:

 < D​​IV提示={{col.dimension1}}> {{col.displayName}}< / DIV>


解决方案

内置的解决方案 - 多一种解决方法 - 在这里:
http://plnkr.co/edit/0PMmrw?p=$p$pview

下面是摘录。我让显示名的对象,而不是一个字符串:

  columnDefs:
    {场:'complex.name,显示名:名称},
    {场:'complex.active',
    cellClass:溢出可见,
    显示名:{名称:进行中,提示:测试},
    headerCellTemplate:header_template.html',
    cellTemplate:'checkBoxTemplate.html'}]

,然后参考它在细胞中的模板,像这样:

 < D​​IV NG点击=col.sort($事件)NG-CLASS ='小马'+ col.index级=ngHeaderText工具提示={ {col.displayName.tooltip}}> {{col.displayName.name}}< / DIV>

修改


这里的问题是,由于NG-电网的实现需要显示名是一个字符串(至少在V2.0.7),它会抛出错误;它调用col.displayName.toLowerCase()。

Using ng-grid, I'd like to add my own tooltip, using a header cell template. To do so I'd like to create a column property called "tooltip" for instance. Tried that and it doesn't show up in the col properties. What do you think about giving us that functionality. Otherwise I create a new template in each case?

See plunkr: http://plnkr.co/edit/lSf4XK?p=preview

Ideally, the gridOptions would contain columnDefs like this:

  columnDefs: [
    {field: 'complex.name', displayName: 'Name', headerCellTemplate:'header_template2.html'},
    {field:'complex.active', 
    dimension1: "Testing",
    displayName: 'In Progress', 
    headerCellTemplate:'header_template.html', 
    cellTemplate : 'checkBoxTemplate.html'}]

and that dimension1 property would be accessible in the template like so:

<div tooltip="{{col.dimension1}}">{{col.displayName}}</div>

解决方案

Built a solution - more of a workaround - here: http://plnkr.co/edit/0PMmrw?p=preview

Here's an excerpt. I make displayName an object instead of a string:

  columnDefs: [
    {field: 'complex.name', displayName: 'Name'},
    {field:'complex.active', 
    cellClass: 'overflow-visible',
    displayName: {name:'In Progress', tooltip:'Testing'}, 
    headerCellTemplate:'header_template.html', 
    cellTemplate : 'checkBoxTemplate.html'}]

And then refer to it in the cell template like so:

  <div ng-click="col.sort($event)" ng-class="'colt' + col.index" class="ngHeaderText" tooltip="{{col.displayName.tooltip}}">{{col.displayName.name}}</div>

Edit
The problem with this is that it will throw errors because the implementation of ng-grid expects displayName to be a string (at least in v2.0.7); it calls col.displayName.toLowerCase().

这篇关于一个属性添加到NG-网格列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆