easyui部分组件使用经验

easyui部分组件使用经验

easyui-switchbutton

需要实现在数据表格中有一列如下图,最开始参考官网,不完全可用,还得借助百度:
在这里插入图片描述

 //其中onclick都是不可行的,是错误示例
 {
title: '状态',field: 'ie',align: "center",width: 100,
formatter: function (value, row, index) {
    if (value === 'Y') {
                        return "<form><input id='" + row.id + "'  class='easyui-switchbutton switchBtn' data-options=\"onText:'启用',offText:'禁用' \" checked onclick=changeState1(" + JSON.stringify(row).replace(/"/g, '&quot;') + ")></form>"
                    } else if (value === 'N') {      return "<form><input id='" + row.id + "'  class=\"easyui-switchbutton switchBtn\" data-options=\"onText:'启用',offText:'禁用', onclick: changeState1(" + JSON.stringify(row).replace(/"/g, '&quot;') + ") \"></form>"
                    }
                }
            }, `
  //简单的正确示例
  return "<form><input id='" + row.id + "'  class='easyui-switchbutton switchBtn'></form>"
//正确示范
 onLoadSuccess: function (data) {
   
                    $('.editParam').linkbutton();
                    $(".switchBtn").switchbutton({
   
                        height: 18,
                        onText: "启用",
                        offText: "停用",
                        onChange: function (checked) {
   
                            //Y启用 true N禁用 false
                            var state = 'Y';
                            if (!checked) {
   
                                state = 'N';
                            }
                            var id = $(this).attr("id");
     //错误示范
     // $('#sw111').switchbutton({
   
        //     onChange: function(data){
   
        //         console.log("datasw111:" +JSON.stringify(data))
        // }});
        // $('.switchBtn').switchbutton({
   
        //     onChange: function(data){
   
        //         console.log("datasw:" +JSON.stringify(data))
        //     }
        // })                       

1.class=‘easyui-switchbutton switchBtn’ 并且配合 ( " . s w i t c h B t n " ) . s w i t c h b u t t o n ( ) 才 能 显 示 成 功 2. 点 击 该 按 钮 调 用 启 用 禁 用 方 法 , 在 单 行 o n c l i c k 调 用 外 部 方 法 不 行 , 使 用 (".switchBtn").switchbutton()才能显示成功 2.点击该按钮调用启用禁用方法,在单行onclick调用外部方法不行,使用 (".switchBtn").switchb

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值