jqGrid行数据中如何添加下拉选 select

本文探讨了在表单中使用Ajax进行动态赋值的方法,通过获取对象列表和字典数据来丰富表单选择项,实现数据的实时更新与编辑。详细介绍了如何在表单字段中设置不可编辑属性,以及如何通过Ajax调用后台接口获取数据,并将这些数据转换为可选的下拉列表。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

columnModel: [
	//Ajax查询,动态赋值,表单不能编辑
	{header:'${text("对象")}', name:'', width:150, editable:false, edittype:'select',formatter : 'select', editoptions:{'class':'form-control',value:getObjectList()}},
{header:'${text("2对象")}', name:'pay2Id',  editable:true, edittype:'select',editoptions:{'class':'form-control',
				items: $.merge([{institutionName:' ',id:''}], getObjectList()),
				itemLabel: 'institutionName', itemValue: 'id', dataInit: function(element){
					$(element).select2().on("change",function(){$(this).valid()});
				}
			}
		},
	//取字典
	{header:'${text("状态")}', name:'', width:100,
		editable:true, edittype:'select', editoptions:{'class':'form-control',
			items: $.merge([{dictLabel:' ',dictValue:''}], ${@DictUtils.getDictListJson('use_status')}),
			itemLabel: 'dictLabel', itemValue: 'dictValue', dataInit: function(element){
				$(element).select2().on("change",function(){$(this).valid()});
			}
		}
	},
],

    /*获取对象下拉选*/
    function getObjectList() {
        var strObjectList="";
        $.ajax({
            type:"post",
            async:false,
            url:"${ctx}/xxx/xxx/xxx/findObjectList",
            data: {
            },
            success:function(data){
                if (data.length>0) {
                    strObjectList += ""+":"+"请xuanze"+";";
                    for(var i = 0; i<data.length; i++){
                        if(i != data.length- 1){
                            strObjectList += data[i].id+":"+data[i].xxName+";";
                        }else{
                            strObjectList += data[i].id+":"+data[i].xxName;
                        }
                    }
                    strObjectList = strObjectList.substring(0,strObjectList.length -1);
                }
            }
        });
        return strObjectList;
    }
	

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值