diff --git a/web/pgadmin/static/js/backgrid/backgrid.pgadmin.js b/web/pgadmin/static/js/backgrid/backgrid.pgadmin.js index b12c089c3..41143a33e 100644 --- a/web/pgadmin/static/js/backgrid/backgrid.pgadmin.js +++ b/web/pgadmin/static/js/backgrid/backgrid.pgadmin.js @@ -289,6 +289,83 @@ } }); + + /* + * Select2Cell for backgrid. + */ + var Select2Cell = Backgrid.Extension.Select2Cell = Backgrid.Cell.extend({ + + className: "select2-cell", + + events: { + "change": "onSave", + "select2:unselect": "onSave" + }, + template: _.template( + '', + null, + {variable: null} + ), + render: function () { + var col = _.defaults(this.column.toJSON(), this.defaults), + model = this.model, column = this.column, + editable = Backgrid.callByNeed(col.editable, column, model), + optionValues = this.column.get('optionValues'); + + this.$el.empty(); + + if (!_.isArray(optionValues)) throw new TypeError("optionValues must be an array"); + + /* Add empty option as Select2 requires any empty '