SitePen / dgrid

A lightweight, mobile-ready, data-driven, modular grid widget designed for use with dstore
http://dgrid.io/
Other
628 stars 295 forks source link

Change text filed attribute in a specific row dojo dgrid in edit mode #1411

Closed michaelsamirg closed 4 years ago

michaelsamirg commented 6 years ago

I want to change a text field attribute in a specific row.

I have an editable dGrid with 5 fields, 2 of them are disabled and their values change when a DDL value is changed, now what I want is when the value of the DLL is changed to specific value, the two disabled filed become enabled for edit only for this row, and then be disabled again when choosing other values in the select, here's a screenshot of the grid

lduvg 1

And here's the creation of the grid

 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,
        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,
            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: []})));
edhager commented 6 years ago

If you are setting the value of "store" on the grid, you are using a old version of dgrid. Can you tell me which version you are using?

msssk commented 4 years ago

This is the bug tracker for dgrid. Please refer to documentation & support for usage help.