Jquery icheck插件

时间:2018-01-11 18:59:40

标签: jqgrid icheck

我想在JqGrid上应用iCheck样式,我在网上尝试了很多解决方案。我需要设置格式化程序或设置列类型复选框。我试图设置格式化程序和插入复选框,我也尝试设置类型复选框和设置格式,但如果我通过jquery选择复选框,则样式消失

$.jgrid.defaults.responsive = true;
    $.jgrid.defaults.styleUI = 'Bootstrap';
    jQuery("#grdRoles").jqGrid({
        url: rolesUrl,
        datatype: "json",
        colModel: [
            { name: 'RoleId', index: 'Id', label: 'Id', search: false, hidden: true, key: true },
            {
                name: 'RoleStatus',
                label: 'RoleStatus',
                editable: true,
                edittype: 'checkbox',
                editoptions: { value: "True:False" },
                formatter: "checkbox",
                formatoptions: { disabled: false }


            },
            { name: 'RoleName', index: 'RoleName', label: 'RoleName', width: 80, search: false },
        ],

        onSelectRow: function (rowid, state) {


            var $RowIdValue = $("#jqg_" + $.jgrid.jqID(this.id + "_" + rowid)).next("a");
            var SelecterId = $RowIdValue.prevObject[0];
            var $a = $("div.icheckbox_flat-green")
            $.each($a, function (index) {
                var item = $a[index];
                $.each(item.children, function (index1) {

                    var childrenitem = item.children[index1];
                    if (childrenitem === SelecterId) {

                        if (state) {
                            item.className = "icheckbox_flat-green checked";
                        } else {
                            item.className = "icheckbox_flat-green";
                        }
                    }

                })

            });

        },
        loadComplete: function () {

            var $checkboxes = $("#grdRoles [name=RoleStatus]");
            //$checkboxes.prettyCheckable();
            $checkboxes.iCheck({
                checkboxClass: 'icheckbox_flat-green',
                radioClass: 'iradio_flat-green'
            });


            //var $checkboxes = $("#grdRoles input[type=checkbox]");
            //$checkboxes.iCheck({
            //    checkboxClass: 'icheckbox_flat-green',
            //    radioClass: 'iradio_flat-green'
            //});

            //$checkboxes.on('ifChanged', function (event) {
            //   console.log('check')
            //});


        }

    });

1 个答案:

答案 0 :(得分:0)

我把它放了 loadComplete:function(){

*