Author Topic: set default value for pqgrid column, there is a "Uncaught TypeError: Cannot rede  (Read 329 times)

hyh888

  • Pro Enterprise
  • Full Member
  • *
  • Posts: 142
    • View Profile
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;
                            }
                        });
                    }
                });
            },

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6309
    • View Profile
Same post have been updated with the necessary change to avoid error.