1. 程式人生 > >datagrid裡邊的combobox獲取當前row的索引(總結於EasyUI中文社群群討論)

datagrid裡邊的combobox獲取當前row的索引(總結於EasyUI中文社群群討論)

 datagrid裡邊的combobox獲取當前row的索引,舉個例子: 10個行,同時開啟編輯狀態。
現在,點開第4行的a列的combobox,請問如何在combobox的select裡得到 所在的row 是 第4行?
方案一:  var selections = $("#a").datagrid('getSelections');  方案一被否,編輯狀態下獲取不了selections

正確的做法是: 1.在beginEdit的時候,得到combobox這個editor,為它增加(其實是重寫)onSelect; 2.通過 $(editor.target).parents("tr.datagrid-row").attr("datagrid-row-index")來得到所在資料行的索引   全靠硬生生的html解析,無它