2014-01-22 26 views
0

我對Dojo來說比較陌生。我正在使用DataGrid,在其中一列中有一個文本框。當用戶在特定行的文本輸入中輸入一些數據時,我想知道網格的行索引。如何在Dojo中找到選定的網格行索引

'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. 
} 

有人可以幫助我在這方面。

謝謝, 尼爾默爾庫馬爾博加迪

回答

0

當觀看數據網格的代碼(dojox/grid/cells/_Base要準確)我注意到formatter回調得到兩個參數:

  • 原值
  • 的行索引(inRowIndex

因此,根據你可以n很容易檢索行索引,例如:

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

我認爲你需要整個選定的網格行數據?這是我在我的項目中使用的:

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