easy ui datagrid 简单用法2


一:datagrid增删改查操作

         

       1:查询

             查询不过就是需要一些筛选条件,而datagrid的load方法,可以很好的支持

             向后台提供需要的筛选条件

             $("#dt").datagrid("load",{uername:'aaa'})

            第二个参数就是需要的查询条件,是一个json对象

            传对象的时候可以使用jquery插件把查询条件的表单序列化成json对象

            不用自己去一个一个拼接参数

       2:增删改

            先使用toolbar给datagrid增加增删改查的功能条           

toolbar: [
                    { text: '增加', iconCls: "icon-add", handler: function () { } }, '-',
                    { text: '删除', iconCls: "icon-remove", handler: function () { } }, '-',
                    { text: '修改', iconCls: "icon-edit", handler: function () { } },'-',
                    { text: '查询', iconCls: "icon-search", handler: function () { } }
               ]

            


二:获取datagrid中的editor嵌套对象

      <th id="lineid" data-options="field:'LineId',width:130,
                        formatter:function(value,row){ 
                            return row.LineName;
                        },
                        editor:{
                            type:'combobox',
                            options:{
                                valueField:'LineId',
                                textField:'LineName',
                                url:'/PortList/GetLineAll2',   
                                multiple:true,                           
                                editable:false       
                            }
                        }">航线</th>

      获取第1行的lineid中的嵌套对象

      var ed = $('#dg').datagrid('getEditor', { index: 0 field: 'LineId' });
                if (ed != null) {
                    var LineName = $(ed.target).combobox('getValues');
                    alert(LineName);
                }

      

三:嵌套对应combobox设置默认值

     <th  data-options="field:'ServicePeopleId',width:80,
                                  formatter:function(value,row){ 
                                   return row.ServicePeopleName;
                                  },
                                  editor:{
                                  type:'combobox',
                                  options:{
                                   valueField:'Id',
                                   textField:'RealName',
                                   url:'/xt/GetUser_DM',
                                   editable:false,
                                   onLoadSuccess:function()
                                   {                                          
                                         var myvalue = $(this).combobox('getValue');
                                         if(myvalue == '' || myvalue==null ){  //如果有值就不选择默认的,没有选择时才选择默认值
                                         var data = $(this).combobox('getData');
                                         $(this).combobox('select',data[0].Id);}
                                   }                                       
                                  }
                             }">服务人员</th>

     


四:获取选中行的数据   

            var currentRow = $("#dg_gm").datagrid("getSelections");




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值