具体实现介绍:主要是对动态查询出来的table表单进行单击选中后,将选中的当前行中的数据,返回到当前页面中的text文本框中,进行保存操作。
JS文件相关代码如下:
//加载控件
function LoadControl(){
//数据表加载
$('#tableid').datagrid({ //此处tableid为所需操作的table表单id
title:'查询到的数据', //table表单标题
loadMsg:'正在努力加载数据,请稍后。。。', //查询时出现的加载提示
width:1200,
height:200,
singleSelect:true, //设置选中项只有当前单击的选项,如果改为false,则会出现table表单中同一时间多行被同时选中
fitColumns:true, //设置Columns是否自适应宽度
rownumbers:true, //是否设置自定义的表格行号(1、2、3、4、5...)
panelHeight:'auto' //行高设置,当前为自适应
columns:[[
{ field: 'Serial', title: '', hidden: true //title标签是设置表格列名,hidden为是否隐藏列名
},{
field: 'pbm_so', resizable: true, align: 'center', width: 80, title: 'fistcol' //field为自定义标签,field中的数据为自定义的变量
},{
field: 'location', resizable: true, align: 'center', width: 80, title: 'secondcol' //esizable 是让对象拥有可调整大小的属性,类似于windows文件夹一样
//可以通过拖动边或者角来调整文件夹的大小。
},{
field: 'pbm_partno', resizable: true, align: 'center', width: 150, title: 'thridcol''
}, {
field: 'materialpn', resizable: true, align: 'center', width: 150, title: 'forthcol''
}
]],
//jquery使用queryParams拿参数
queryParams:{
pbm_so: $("#txtSo").val(''), //将当前行的列值赋值给变量
location: $("#txtLocNo").val(''),
pbm_partno: $("#txtPartNo").val(''),
chguser: $("#txtChgUser").val('')
},
//写单击触发事件
onClickRow: function (index, field, value) {
g_index = field.Serial; //获取index行号
$("#txtSo").val(field.pbm_so); //将变量的值赋值给text
$("#txtLocNo").val(field.location);
$("#txtPartNo").val(field.pbm_partno);
$("#txtChgUser").val(field.chguser);
},
onLoadSuccess: function (data) { //加载表单的时候,对表单内行数据进行判断,可以赋颜色,也可以进行其他操作
}
});
}