ParamQuery grid support forum

General Category => Help for ParamQuery Pro => Topic started by: hyh888 on November 21, 2022, 07:08:30 am

Title: set default value for pqgrid column, there is a "Uncaught TypeError: Cannot rede
Post by: hyh888 on November 21, 2022, 07:08:30 am
Wheng using following code to set default value for pqgrid column, there is a "Uncaught TypeError: Cannot redefine property: id"  problem.
The code comes from https://paramquery.com/forum/index.php?topic=4347.0.
            rowTemplate: {},
            complete: function(){
                let rt = this.option('rowTemplate'), cm = this.getColModel();
                cm.forEach(function(col){
                    let def = col.defaultValue, di = col.dataIndx;
                    if( def !== undefined ){
                        Object.defineProperty(rt, di, {
                            enumerable: true,
                            get(){
                                var val = this[ "_" + di];
                                return val == null? def: val;;
                            },
                            set(val){
                                this[ "_" + di ] = val;
                            }
                        });
                    }
                });
            },
Title: Re: set default value for pqgrid column, there is a "Uncaught TypeError: Cannot rede
Post by: paramvir on November 21, 2022, 11:22:56 am
Same post have been updated with the necessary change to avoid error.