我想要在客戶端獲取選定的網格行KeyField值;ASPXGridView ClientSideEvents如何獲取所選行的KeyField值
我曾經嘗試以下,並得到不同的結果:
方法#1
<ClientSideEvents RowClick="function(s, e) {var key= grid.GetSelectedKeysOnPage()[0];}" />
//This gives previous selected rows value everytime
方法2
<ClientSideEvents RowClick="function(s, e) { grid.GetRowValues(grid.GetFocusedRowIndex(), 'MyKeyFieldName', OnGetRowValues); }" />
//This gives previous selected row and also gives an error: "A primary key field specified via the KeyFieldName property is not found in the underlying data source. Make sure.. blabla" But the MyKeyFieldName is true and i dont want to make a callback, i dont want to use this method!
方法#3
<ClientSideEvents RowClick="function(s, e) { grid.GetRowValues(e.visibleIndex, 'MyKeyFieldName', OnGetRowValues); }">
//This gives the same result with Method #2
問題是:我怎麼能發脾氣er KeyField在客戶端RowClick事件中沒有回調或回發的當前選定行的(不是之前但是)的值的KeyField值?
謝謝你,但是這不是我期待的答案。我在問如何在Clientside RowClick事件中收集新選定行的Keyfield值?而ASPxClientGridView.GetSelectedKeysOnPage [0]正在改變,當選擇改變時,它不一樣。 – DortGen 2012-01-15 11:49:07
您是否嘗試過我的解決方案?它產生了什麼結果? – Mikhail 2012-01-15 16:00:34
如果您想使用Mikhail的解決方案,僅供參考;使用SelectionChanged事件的問題:用戶排序或過濾時;存儲的密鑰未更新(SelectionChanged事件未觸發) – kite 2012-09-11 16:03:07