【问题标题】:How to find the selected row index of a grid in Dojo如何在Dojo中找到网格的选定行索引
【发布时间】:2014-02-12 04:25:43
【问题描述】:

我对 Dojo 比较陌生。我正在使用 DataGrid,其中一列中有一个文本框。当用户在特定行的文本输入中输入一些数据时,我想知道网格的行索引。

'name' : 'Partner Column Name',
'field' : 'text',
'width' : '25%',
'field' : 'partnerColumnName',
'text-align': 'center',
'editable' : true,
'type' : dojox.grid.cells._Widget,
'formatter' : function()                             
{
 return new dijit.form.TextBox({style:"width:100%", id: "textBox_"+counter++,          onChange: function ()
{
  // Here I want to know the row index of the grid. 
}

有人可以在这方面帮助我吗?

谢谢, Nirmal Kumar Bhogadi

【问题讨论】:

    标签: datagrid dojo


    【解决方案1】:

    我认为您需要网格的整个选定行数据?这是我在项目中使用的:

    var grid = dijitRegistry.byId('yourGridId');    
    if (!grid || !grid.selection || grid.selection.getSelected()) {
        console.log(grid.selection.getSelected());
    }
    

    【讨论】:

      【解决方案2】:

      在查看数据网格的代码时(准确地说是dojox/grid/cells/_Base),我注意到formatter 回调有两个参数:

      • 原值
      • 行索引 (inRowIndex)

      因此基于此您可以轻松检索行索引,例如:

      formatter: function(myValue, rowIndex) {
          // Do something with rowIndex
      }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-01-04
        • 1970-01-01
        • 2019-05-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多