easyUI中的datagrid的formatter方法中 使用$.ajax()方法绑定多个不同数据源的数据

 1.datagrid 数据源 绑定url: 'data/GetJson.aspx',

2.userRole_id列,显示userRole;userRole的数据源绑定不来自url: 'data/GetJson.aspx',而是来自htmlobj=$.ajax({type:'post',url:'data/GetUserRole.aspx/',data:{userRole_id:value},async:false});  

3.datagrid  应用  formatter:function(value,row){                         
                            htmlobj=$.ajax({type:'post',url:'data/GetUserRole.aspx/',data:{userRole_id:value},async:false});                        
                            return htmlobj.responseText;} 

例子

 <table id="dg" class="easyui-datagrid" title="Row Editing in DataGrid" style="width: 700px;

        height: auto" data-options="
iconCls: 'icon-edit',
singleSelect: true,
toolbar: '#tb',
url: 'data/GetJson.aspx',//datagrid绑定的主要数据源
method: 'get',
onClickRow: onClickRow
">
        <thead>
            <tr>
                <th data-options="field:'user_id',width:80">
                    user_id
                </th>
                <th data-options="field:'userRole_id',width:100,
formatter:function(value,row){                         
                            htmlobj=$.ajax({type:'post',url:'data/GetUserRole.aspx/',data:{userRole_id:value},async:false});      //  获取userrole的值 显示在该列中                
                            return htmlobj.responseText;
},
editor:{
type:'combobox',
options:{
valueField:'userRole_id',
textField:'userRole',
method:'get',
url:'data/GetRoleJson.aspx',
required:true
}

}"

>

                    role
                </th>
                <th data-options="field:'user_name',width:80,align:'right',editor:'textbox'">
                    name
                </th>
                <th data-options="field:'user_pass',width:80,align:'right',editor:'numberbox'">
                    password
                </th>
                <th data-options="field:'dept_name',width:250,editor:'textbox'">
                    department
                </th>
            </tr>
        </thead>
    </table>
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值