Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/extjs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Checkbox 在网格列ExtJs内的一行中显示一组复选框_Checkbox_Extjs_Extjs Grid - Fatal编程技术网

Checkbox 在网格列ExtJs内的一行中显示一组复选框

Checkbox 在网格列ExtJs内的一行中显示一组复选框,checkbox,extjs,extjs-grid,Checkbox,Extjs,Extjs Grid,我是ExtJS新手,我尝试以这种方式显示复选框组: 我有以下代码: Ext.onReady(function() { var ct = Ext.create('Ext.container.Viewport', { layout: 'border', defaults: { collapsible: true, split: true }, items: [{ title: 'Tasks', reg

我是ExtJS新手,我尝试以这种方式显示复选框组:

我有以下代码:

Ext.onReady(function() {

var ct = Ext.create('Ext.container.Viewport', {
    layout: 'border',
    defaults: {
        collapsible: true,
        split: true
    },
    items: [{
        title: 'Tasks',
        region: 'west',
        margins: '5 0 0 0',
        cmargins: '5 5 0 0',
        width: '50%',
        scrollable: true,
        bodyStyle: 'padding:10px',
        html: MyTest.description
    },{
        collapsible: false,
        region: 'center',
        margins: '5 0 0 0',
        items: [{
            xtype: 'grid',
            id: 'MyGridPanel',
            title: 'Test Grid',
            store: {
                fields: ['name', 'permissions'],
                proxy: {
                    type: 'memory',
                    reader: {type: 'json'}
                },
                data: [{
                    name: 'Farms',
                    permissions:{
                        'manage': 1,
                        'clone': 1,
                        'launch': 0,
                        'terminate': 0,
                        'not-owned-farms': 0
                    }
                },{
                    name: 'Alerts',
                    permissions:null
                },{
                    name: 'Servers',
                    permissions:null
                },{
                    name: 'Events and notifications',
                    permissions:null
                },{
                    name: 'Statistics',
                    permissions:null
                },{
                    name: 'Roles',
                    permissions:{
                        'manage':1,
                        'clone':0,
                        'bundletasks':0
                    }
                },{
                    name: 'Scripts',
                    permissions:{
                        'manage':0,
                        'execute':0,
                        'fork':0
                    }
                }]
            },
            columns: [{
                text: 'Name',
                width: 200,
                dataIndex: 'name'
            },{
                text: 'Permissions',

                dataIndex: 'permissions',

        //  I need to insert here a checkbox groups for elements that have permissions I guess. So what should I use here - renderer, handle? 

            }],

        }]
    }]
});
那我应该用什么呢?例如,如果我使用渲染器(不确定是否可以使用它),我可以接收复选框的所有数据(请参见下面的代码),但我不确定如何渲染它

renderer: function(value, meta, rec, rowIdx, colIdx, store, view) {

    var checkboxconfigs = [];
    for (var variable in value) {
        checkboxconfigs.push({
            boxLabel: variable,
            name: variable,
            inputValue: value[variable],
            checked: value[variable]
        })
    }

    var checkboxes = new Ext.form.CheckboxGroup({
        id:'chkGroup',
        fieldLabel: 'Permissions',
        columns: 1,
        items: checkboxconfigs
    });


   // return WHAT?;
}

我将非常感谢您的帮助

您可以按如下方式进行:

renderer: function (value, meta, rec, rowIdx, colIdx, store, view) {
    var doms = '';
    for (var variable in value) {
        var temp = value[variable] === 1 ? 'checked' : '';
        doms += '<input type="checkbox" name="' + variable + '" value="Car" ' + temp + '>' + variable
    }
    return doms;
}
渲染器:函数(值、元、rec、rowIdx、colIdx、存储、视图){
var-doms='';
for(var变量值){
变量温度=值[变量]==1?“已检查”:“”;
doms+=''+变量
}
返回doms;
}

工作。解决方案:

如果要呈现值,请尝试使用以下列定义:

{
    text: 'Permissions',
    dataIndex: 'permissions',
    width: 200,
    renderer: function(value, cell) {
        var s = '';
        for (var index in value) {
            s = s + '<input type="checkbox" ';
            if (value[index] == 1) {
                s = s + 'checked';
            };
            s = s + '>' + index;
        }
        return s;
    }
}
{
文本:“权限”,
dataIndex:'权限',
宽度:200,
渲染器:函数(值、单元格){
var s='';
for(价值中的var指数){
s=s+“”+指数;
}
返回s;
}
}
注意事项:


使用ExtJS 4.2进行测试。

Wow。谢谢!谢谢。终于明白了!