diff --git a/web/pgadmin/static/js/backgrid/backgrid.pgadmin.js b/web/pgadmin/static/js/backgrid/backgrid.pgadmin.js index 55ba7c0..d157999 100644 --- a/web/pgadmin/static/js/backgrid/backgrid.pgadmin.js +++ b/web/pgadmin/static/js/backgrid/backgrid.pgadmin.js @@ -22,6 +22,12 @@ factory(root, root._, (root.jQuery || root.Zepto || root.ender || root.$), root.Backbone, root.Backform); } } (this, function(root, _, $, Backbone, Backform, Alertify) { + /** + * It has already been loaded once. + **/ +// if (Backgrid.Extension.ObjectCellEditor) { +// return Backgrid; +// } /* * Add mechanism in backgrid to render different types of cells in @@ -802,6 +808,47 @@ }, }); + /** + * DependentCell functions can be used with the different cell type in order + * to setup the callback for the depedent attribute change in the model. + * + * Please implement the 'dependentChanged' as the callback in the used cell. + * + * @class Backgrid.Extension.DependentCell + **/ + var DependentCell = Backgrid.Extension.DependentCell = function() {}; + + _.extend( + DependentCell.prototype, { + initialize: function(){ + // Listen to the dependent fields in the model for any change + var deps = this.column.get('deps'); + var self = this; + + if (deps && _.isArray(deps)) { + _.each(deps, function(d) { + attrArr = d.split('.'); + name = attrArr.shift(); + self.listenTo(self.model, "change:" + name, self.dependentChanged); + }); + } + }, + remove: function() { + // Remove the events for the dependent fields in the model + var self = this, + deps = self.column.get('deps'); + + if (deps && _.isArray(deps)) { + _.each(deps, function(d) { + attrArr = d.split('.'); + name = attrArr.shift(); + + self.stopListening(self.model, "change:" + name, self.dependentChanged); + }); + } + } + }); + return Backgrid; }));