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

hyh888

  • Pro Enterprise
  • Full Member
  • *
  • Posts: 102
    • 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: 5787
    • View Profile
[ Only Pro members may read this post. ]