日期:2014-05-16  浏览次数:20345 次

如何获取datagrid中input元素的值
datagrid中某列使用了formatter,方法如下:
function formateParam(value, row, index) {
if (row.PARAM_CODE == "AutoAllot") {
if (value == 1) {
return '<input type="radio" name="param_value"  id="onRadio" value="1" checked="checked"/>开启' + '<input type="radio" name="param_value" id="offRadio" value="0" />关闭';
} else
return '<input type="radio" name="param_value"  id="onRadio" value="1" />开启' + '<input type="radio" name="param_value" id="offRadio" value="0" checked="checked"/>关闭';
} else
return "<input type='text' style='width:30px;' name='param_value' value='"
+ value + "'>(元)";
}

效果图:


问题是我如何 获取如 单选框的value以及文本框的值。


function save() {
var selected = $("#gridlist").datagrid("getSelected");
if (!selected)
return;
$("#gridlist").datagrid("endEdit", index);
alert(selected.PARAM_VALUE);...}

点击保存save,弹出的值是5,怎么改变文本框的值都是弹出的都是5,如何让它弹出我输入的值呢?
datagrid easyui JavaScript

------解决方案--------------------
你的文本框为什么跟单选按钮起的名字一样呢,至少换个名字吧
"<input type='text' style='width:30px;' name='param_value1' value='">

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
function save(){
$(function(){
alert($("#gridlist input[name='param_value1']").val());
alert($("#gridlist input[name='param_value']").val());
})
}
</script>