jqueryEasyui常用代码
程序员文章站
2022-06-08 23:46:08
...
//查询:
function doSearch(form){
var fields =$('#queryForm').serializeArray();
var $fm = $(form);
var params = $fm.datagrid('options').queryParams;
$.each( fields, function(i, field){
params[field.name] = field.value;
});
$fm.datagrid('reload');
}
//查看[弹窗版]:
formatter : function(value, rowData, rowIndex) {
return "<a href='javascript:void(0)' onclick='relation_ref_query_onView("+rowIndex+")' >" + value + "</a>";
}
function relation_ref_query_onView(index) {
var d = $query_datagrid.datagrid("getData").rows[index];
var p = ysaxui.dialog({
title : '查看关系规格',
href : viewRelationUrl,
width : 765,
height : 375,
buttons : [ {
text : '关闭',
iconCls : 'ope-close',
handler : function() {
p.dialog('close');
}
}],
onLoad : function() {
var f = p.find('form')
f.form('load', d);
}
});
};
//弹窗
/***
* 公用规格选择弹窗
* @param targetCompId 规格ID存储文本框的ID
* @param targetCompText 规格名称存储文本框的ID
* @param specType 规格选择类型 e:实体规格,r:关系规格(两类弹窗数据)
* @param level 显示层级级别
* {0:无限制,显示所有 1:只显示大类规格
* 2:只显示细类规格 3:只显示规格
* 4:只显示大类和细类}
* @param repTypeId 关系类型
* @return
*/
function open_parent_specWindow(targetCompId,targetCompText,specType,level,rp,repTypeId) {
var hrefUrl = '/mds/oss/content/input/win/openWin_parent_spec_single.html';
//不同弹窗页面
if(rp){
hrefUrl = '/mds/oss/content/input/win/openWin_parent_relation_spec_single.html';
}
var openUrl = "";
if(specType=='e'){
openUrl = entityListUrl;
}else if(specType=='r'){
openUrl = relationListUrl;
}else{
alert('参数设置有误! pub_mds.js');
return;
}
if(!level){
level = "0";
}
var $datagrid = null;
var p = yasxui.dialog({
title : '选择规格',
iconCls : 'pag-add',
href : hrefUrl,
width : 600,
height : 350,
buttons : [ {
text : '确定',
iconCls : 'ope-save',
handler : function() {
var selected = $datagrid.datagrid('getSelected');
if (selected == null) {
$.messager.alert('系统提示', '请选择对象');
} else {
$("#"+targetCompText).val((selected["code"]+"/"+selected["name"]));
$("#"+targetCompId).val((selected["oid"]));
p.dialog('close');
}
}
}, {
text : '取消',
iconCls : 'ope-close',
handler : function() {
p.dialog('close');
}
} ],
onLoad : function() {
//弹窗页面列表数据
$datagrid = $('#domain_ref_single_chooser_grid');
$datagrid.datagrid({
url : openUrl,
queryParams:{
'level' : level,
'relationTypeId':repTypeId
},
fit : true,
singleSelect : true,
pagination : true,
pagePosition : 'bottom',
pageSize : 10,
pageList : [10, 20, 30, 50, 100],
fitColumns : true,
nowrap : true,
border : false,
idField : 'id',
frozenColumns : [ [ {
field : 'id',
title : '选择',
width : 40,
sortable : false,
formatter : function(value, rowData) {
return '<input type="radio" name="domain_ref_single_chooser_grid_radio" value="' + value + '">';
}
} ] ],
columns : [ [ {
title : '编号',
field : 'code',
width : 205
}, {
title : '名称',
field : 'name',
width : 350,
sortable : true
} ] ],
onClickRow:function() {
var selected = $datagrid.datagrid('getSelected');
if (selected){
var index=$datagrid.datagrid('getRowIndex', selected);
$('input:radio[name="domain_ref_single_chooser_grid_radio"]').get(index).checked = true;
}}
});
$("#spec_levelId").attr("value","level");
//弹窗查询
$("#refChooseButton").click(function(){
$('#domain_ref_single_chooser_grid').datagrid('load', yxui.serializeObject($("#specWinForm").form()));
});
var specVal ;
switch(level){
case "1":
specVal = 1060 ;break;
case "2":
specVal = 1061; break;
case "3":
specVal = 1062; break;
}
//进入时默认选中
if(specVal){
p.find("#specLevelId").combobox('select', specVal) ;
}
}
});
};
//弹窗页面openWin_parent_spec_single.html:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<div class="easyui-layout" data-options="fit:true" style="padding:1px;overflow:hidden;">
<!-- north -->
<div data-options="region:'north',border:false" style="height:40px;">
<form class="yxForm" id="specWinForm">
<input type="hidden" name="level" id="spec_levelId">
<table class="tableForm_L" style="margin-top:3px" width="99%" border="0" cellpadding="0" cellspacing="1">
<tr>
<th width="10%">编号/名称</th>
<td width="40%"><input name="param" /></td>
<th width="10%">规格层级</th>
<td width="40%"><input name="specLevelId" id="specLevelId" class="easyui-combobox" data-options="panelHeight:'auto',editable:false,readonly:true,valueField:'value',textField:'label',data: levelJson" /> <a href="#" id="refChooseButton" class="easyui-linkbutton" data-options="iconCls:'ope-search'" style="height:21px;" >查询 </a></td>
</tr>
</table>
</form>
</div>
<!-- center -->
<div data-options="region:'center',border:false">
<div id="domain_ref_single_chooser_grid"></div>
</div>
</div>
。。
下一篇: jqueryeasyUI(3 元素拖动)