zoukankan      html  css  js  c++  java
  • DOJO复选框操作

    代码
     1 /*
     2 必须引入dojo框架
     3 通常适用于一个容器中全选或是反选的操作
     4 同时检查是否有选中
     5 author:rnn
     6 */
     7 dojo.declare(
    "CheckboxClass",
    null,
    {
        container: "tableId", /*所包含的容器ID*/
        checkboxes: null, /*所有的复选框集合,相当于一个nodeList*/
        count: 0, /*当前复选框个数*/
        selectedCount: 0, /*当前容易中复选框被选中的数目*/
        buttonType: 1, /*负责选择复选框的按钮类型 1表示自身在容器中 2表示在容器外*/
        constructor: function (container, buttonType) {
            this.container = container;
            this.buttonType = buttonType;
            this.checkboxes = dojo.filter(dojo.query("input", dojo.byId(this.container)), function (item) {
                return item.type == "checkbox";
            });
            this.count = this.checkboxes.length - 1;
            var index = 0;
            var currentIndex = 1;
            if (this.buttonType == 2) {
                this.count = this.count + 1;
                currentIndex = 0;
            }
            dojo.forEach(this.checkboxes, function (item) {
                if (index >= currentIndex) {
                    dojo.connect(item, "click", ItemCheckboxClick);
                }
                index++;
            });
        }, /*构造函数,初始化一些数据*/
        Select: function (buttonId) {
            var isChecked = dojo.byId(buttonId).checked;
            if (isChecked) {
                dojo.forEach(this.checkboxes, function (item) {
                    item.checked = true;
                });
                this.selectedCount = this.count;
            }
            else {
                dojo.forEach(this.checkboxes, function (item) {
                    item.checked = false;
                });
                this.selectedCount = 0;
            }
        }, /*全选事件*/
        CheckSelectedCount: function () {
            if (this.selectedCount <= 0) {
                alert("未选中任何数据");
                return false;
            }
            return true;
        },
        SetSelectCount: function (type) {
            if (type == 1) {
                this.selectedCount = this.selectedCount + 1;
            }
            else {
                this.selectedCount = this.selectedCount - 1;
            }
        }
    }
    );
  • 相关阅读:
    npm ERR! shasum check failed for
    使用js闭包封装一个原生的模态框
    使用weexplus + vue开发APP的填坑之旅
    weex 中出现 loading无法关闭
    weex create test-app Error: Cannot find module '../package.json'
    flutter 填坑之旅(dart学习笔记篇)
    各种版本的Linux 镜像下载网址
    在vue 项目中嵌入jsp页面
    mahout 推荐引擎的相关介绍,理解,如何应用。(2)
    mahout 推荐引擎的相关介绍,理解,如何应用。(1)
  • 原文地址:https://www.cnblogs.com/kimbosung/p/1780251.html
Copyright © 2011-2022 走看看