在编辑模式下更改特定行dojo dgrid中的文本字段属性

时间:2017-11-02 09:47:56

标签: dojo dgrid

我想更改特定行中的文本字段属性。

我有一个带有5个字段的可编辑dGrid,其中2个被禁用,当选择字段值更改时它们的值会发生变化,现在我想当select的值更改为特定值时,启用了两个禁用字段仅用于此行的编辑,然后在选择中选择其他值时再次禁用,这是网格的屏幕截图

grid view

这是网格的创建

 this.productStore = new Memory({idProperty: 'id', data: []});
 this.productObjStore = new ObjectStore({objectStore: 
 this.productStore});
        var productColumn = {
            field: 'productServiceId', 
            label: dojoConfig.i18n.productOrService, 
            className: 'hand',
            editor: Select,
            autoSave: true,
            editorArgs: {
                searchAttr: 'name',
                labelAttr: "name",
                style: 'width: 95%',
                store: this.productObjStore,
                required: true,
            },
            renderCell: function(object, data, td, options){
                if(data != ''&& data != dojoConfig.i18n.addNewProduct){
                    td.innerHTML = this.editorArgs.store.get(data).label;
                }
            }
        };

        var quantityColumn = {
            field: 'quantity', 
            label: dojoConfig.i18n.quantity, 
            className: 'hand',
            editor: TextBox,
            autoSave: true,
            editorArgs: {
                placeHolder: '#####',
                regExp: dojoConfig.regExps.intExp,
                trim: true,
                style: 'width: 100%',
                invalidMessage: dojoConfig.i18n.error_quantityIsZero,
                validator: function(){

                    if( this.value > 0)
                        return true;

                    return false;
                }
            }
        };
        var me=this
        var rateColumn = {
                field: 'rate', 
                label: dojoConfig.i18n.rate, 
                className: 'hand',
                editor: TextBox,
                autoSave: true,
                editorArgs: {
                    disabled: true,
                    placeHolder: '#####.##',
                    regExp: dojoConfig.regExps.floatExp,
                    trim: true,
                    style: 'width: 100%',
                }
            };

        var amountColumn = {
            field: 'amount', 
            label: dojoConfig.i18n.amount, 
            className: 'hand',
            editor: TextBox,
            editorArgs: {
                disabled: true,
                placeHolder: '#####.##',
                regExp: dojoConfig.regExps.floatExp,
                trim: true,
                style: 'width: 100%',
            }
        };

        this.discountStore = new Memory({idProperty: 'id', data: []});
        var discountColumn = {
            field: 'discount', 
            label: dojoConfig.i18n.lineDiscount, 
            className: 'hand',
            editor: Select,
            autoSave: true,
            editorArgs: {
                searchAttr: 'name',
                labelAttr: "name",
                style: 'width: 99%',
                store: this.discountStore,
                required: false,
                value:null
            },
            renderCell: function(object, data, td, options){
                if(data != '')
                    td.innerHTML = this.editorArgs.store.get(data).label;
            }
        };

        this._grid = new Grid({
            autoHeight: true,
            showToolbar: true,
            //label: dojoConfig.i18n.invoiceLines,
            style: 'width: 100%; max-height: 200px; margin-top: 1px;',
            columns : [
                {field: 'id', label: 'ID', hidden: true, unhidable: true},
                productColumn,
                {field: 'description' ,label: dojoConfig.i18n.description, dismissOnEnter: false, editor: 'textarea', autoSave: true, renderCell: function(object, data, td, options){
                    td.innerHTML = data;
                }},
                quantityColumn,
                rateColumn,
            //  discountColumn,
                amountColumn,
                {field: 'taxable', style:'width:50%', label: dojoConfig.i18n.taxable, editor: CheckBox, hidden: true, unhidable: true}
            ],
            contextMenuInfo: [
                {label: dojoConfig.i18n.new_, iconClass: 'newIcon', onClick: this.addProduct},
                {label: dojoConfig.i18n.remove, iconClass: 'deleteIcon', onClick: this.deleteProduct, needSelection: true}
            ],
            contextHandler: this,
            selectionMode : 'single', // for Selection; only select a single row at a time
            cellNavigation : false,
            colspan: 5
        });
        this._grid.set('store', new Observable(new Memory({idProperty: 'id', data: []})));

由于

0 个答案:

没有答案