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;
            }
        }
    }
    );
  • 相关阅读:
    Bayesian CTR Prediction for Bing
    Gaussian and Truncated Gaussian
    An Introduction to Variational Methods (5.3)
    An Introduction to Variational Methods (5.2)
    An Introduction to Variational Methods (5.1)
    Variational Bayes
    微软的一篇ctr预估的论文:Web-Scale Bayesian Click-Through Rate Prediction for Sponsored Search Advertising in Microsoft’s Bing Search Engine。
    第五十二课、命令行参数的应用------------------狄泰软件学院
    第五十一课、程序中的配置文件------------------狄泰软件学院
    第五十课、关于对话框(About)------------------狄泰软件学院
  • 原文地址:https://www.cnblogs.com/kimbosung/p/1780251.html
Copyright © 2011-2022 走看看