mardi 24 avril 2018

Display group of checkboxes in a row inside the grid column ExJs

I am new to ExJs and I am trying to display the group of checkboxes in this way grid

I have the following code

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 checkbox groups for elements that have permissions in grid column here I quess. So what should I use here - renderer, handle? 

            }],

        }]
    }]
});

So what should I use for that? For example if I use renderer (not sure if it's ok to use it) I can receive all the data for checkboxes (see code below), but I am not sure how to render it.

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?;
}

I would be grateful for help!




Aucun commentaire:

Enregistrer un commentaire