描述:
因为combogrid据表格下拉框结合了可编辑文本框控件和下拉数据表格面板控件,该控件允许用户快速查找和选择,并且带有分页,当选中的数据在第二页的时候,初始化加载会出现无法选中的情况
解决思路:
把选中的数据,在修改页面加载的时候尽量放在第一页
前台:
$('#custId').combogrid({
url:"${g.createLinkTo(dir:'businessDpartment',file:'getdata')}?pdata=${result.custId}",
height:28,
panelWidth: 480,
panelHeight:400,
editable:false,
pageSize:1000,
idField: 'cust_id',
textField: 'ch_name',
required:true,
multiple:true,
pagination:true,
editable:false,
fitColumns:true,
toolbar:"客户编号/名称: ",
columns:[[
{field:'cust_no',title:"客户编号",width:120,align:"center",sortable:false},
{field:'ch_name',title:"客户中文名",width:120,align:"center",sortable:false},
]],
onLoadSuccess:function(data){
var map={};
var res0="${result.custId}";
var res1= res0.split(",");
console.log(res1);
console.log(res0);
$("#custId").combogrid('setValues',res1)
}
});
后台:
def getdata(){
def sql=new Sql(dataSource)
def cons = []
def wheresql = ""
def chName=BaseUtil.checkNull(params["chName"]);
def searchValue=BaseUtil.checkNull(params.searchValue)
def pdata = BaseUtil.checkNull(params["pdata"]);
def pIds=[]
if(chName){
wheresql=" and ch_name like ? ";
cons.push('%'+chName+'%')
}
if(searchValue){
wheresql=" and (cust_no like ? or ch_name like ?)";
cons.push('%'+searchValue+'%')
cons.push('%'+searchValue+'%')
}
def sb=new StringBuffer()
if(pdata!=""){
pdata.split(",").each {
def String=
sb.append("'${it.toString().trim()}'")
sb.append(",")
}
sb.delete(sb.lastIndexOf(","),sb.lastIndexOf(",")+1)
wheresql=" and a.cust_id not in ("+sb.toString()+") "
}
def sqlp = []
sqlp.addAll(cons)
def sqlt = "select count(cust_id) rowtotal from pctm_sys_cust a where del_flag='0'"+wheresql
def sqld = """
select a.cust_id,a.cust_no,a.ch_name,a.created_stamp from pctm_sys_cust a
left outer join sys_dic d on d.dic_type='3004' and a.cust_no=d.dic_value
where a.del_flag='0'
"""+wheresql
def results=page(sqlt,sqld,sqlp,"created_stamp",[:])
if(pdata && params.page=="1"){
def sql1="""select a.cust_id,a.cust_no,a.ch_name from pctm_sys_cust a
left outer join sys_dic d on d.dic_type='3004' and a.cust_no=d.dic_value
where a.del_flag='0' and a.cust_id in ( """+sb.toString()+""" )"""
def chIds=sql.rows(sql1)
def arrs=new ArrayList()
arrs.addAll(chIds)
arrs.addAll(results.rows)
results.rows=arrs
}
render results as JSON
}