【问题标题】:extjs decimal places rendererextjs 小数位渲染器
【发布时间】:2011-04-05 13:54:20
【问题描述】:

在extjs中,对于record对象,是否有awy获取特定的数据索引。我需要的是这个: 我有一个格式化小数的渲染器函数。如果记录的 dataIndex 是“dollaramount”,我以一种方式格式化。如果有别的,我用另一种方式格式化。 所以函数是:

decimalsRenderer: function(value, metaData, record, rowIndex, colIndex, store){
if (record.data.index =='amount')
//  format using 2 decimals
else
//format using 3 decimals

},

但是record.data.index 是不允许的。我该怎么做?

【问题讨论】:

    标签: extjs


    【解决方案1】:

    我认为您混淆了列和记录。
    Record 没有 dataIndex 但 Column 有一个。
    列的 dataIndex 告诉网格“对于这个列,我们要查看存储中的这个特定字段

    也就是说,您可以通过以下方式在列渲染器中获取数据索引,即字段名称(从商店的角度来看)-

    //columnIndex is availble in renderer fn
    var fieldName = grid.getColumnModel().getDataIndex(columnIndex); 
    //Do your thing. check if fieldName is amount
    

    参考 - ColumnModel

    【讨论】:

      猜你喜欢
      • 2015-02-02
      • 1970-01-01
      • 2011-11-17
      • 2011-07-31
      • 1970-01-01
      • 2011-11-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多