jqGrid如何从下拉单元格中获取所选文本

时间:2013-05-21 21:12:16

标签: jqgrid

以下是显示下拉列表的单元格的colModel。我想在下拉列表中选择文本

{name:'pdInstanceType', edittype:'select', formatter:'select', 
editable:true, editoptions:{value:"1:Test1;2:Test2"}}

以下代码为我提供了所选值(1或2)而不是文本(Test1或Test2)

jQuery("#tableId").jqGrid('getCell', rowId, 'pdInstanceType');

有没有办法获取所选文字?非常感谢任何投入!

2 个答案:

答案 0 :(得分:3)

对于其他正在查找类似问题的人,我可以通过以下方式获取jqGrid单元格中下拉列表的选定文本。

var dropdown = jQuery('#' + rowId + 'pdInstanceType')[0];
var selectedOption = dropdown.options[dropdown.selectedIndex];
var selectedText = selectedOption.text; 

答案 1 :(得分:1)

使用所有RRK(v1.8.2)的代码与jQuery的代码相同:

var stringVal = $('#' + rowId + 'pdInstanceType').val(); // (Returns string)