如題,在treegrid里,按照api里getEditor方法的說明,
getEditor
options
Get the specified editor, the options contains two properties:
index: the row index.
field: the field name.
var nameEditor=$('#menuTable').treegrid('getEditor', {id:editingId,field:"name"});
這樣應該可以取到editor對象,但是測試發現只能獲取到nameEditor=null,測試多次,很是惱火。
后來比較了下datagrid里的getEditor方法,
getEditor
param Get the specified editor, the param contains two properties:
id: the row node id.
field: the field name.
嘗試着把上面treegrid getEditor中的id參數換成了index,值仍然使用id的值,果然,可以獲取到editor對象了,再對此對象進行了一番屬性遍歷之后,終於找到了問題的解決辦法,如下:
var nameEditor=$('#menuTable').treegrid('getEditor', {index:editingId,field:"name"}); var name=nameEditor.target.val();
由此,我敢保證官網api中關於treegrid的getEditor方法的說明是錯誤的,如果我的推測錯誤或者你有更好的思路或者解決辦法,歡迎交流。