mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Resolved an issue setting proper optionsValues for the Select2Cell.
This commit is contained in:
committed by
Ashesh Vashi
parent
df594d56e5
commit
fe05f2d0c6
@@ -294,29 +294,29 @@
|
|||||||
* Select2Cell for backgrid.
|
* Select2Cell for backgrid.
|
||||||
*/
|
*/
|
||||||
var Select2Cell = Backgrid.Extension.Select2Cell = Backgrid.Cell.extend({
|
var Select2Cell = Backgrid.Extension.Select2Cell = Backgrid.Cell.extend({
|
||||||
|
|
||||||
className: "select2-cell",
|
className: "select2-cell",
|
||||||
|
defaults: _.defaults({
|
||||||
|
select2: {}
|
||||||
|
}, Backgrid.Cell.prototype.defaults),
|
||||||
events: {
|
events: {
|
||||||
"change": "onSave",
|
"change": "onSave",
|
||||||
"select2:unselect": "onSave"
|
"select2:unselect": "onSave"
|
||||||
},
|
},
|
||||||
template: _.template(
|
template: _.template(
|
||||||
'<option value="<%- value %>" <%= selected ? \'selected="selected"\' : "" %>><%- text %></option>',
|
'<option value="<%- value %>" <%= selected ? \'selected="selected"\' : "" %>><%- text %></option>'
|
||||||
null,
|
|
||||||
{variable: null}
|
|
||||||
),
|
),
|
||||||
render: function () {
|
render: function () {
|
||||||
var col = _.defaults(this.column.toJSON(), this.defaults),
|
var col = _.defaults(this.column.toJSON(), this.defaults),
|
||||||
model = this.model, column = this.column,
|
model = this.model, column = this.column,
|
||||||
editable = Backgrid.callByNeed(col.editable, column, model),
|
editable = Backgrid.callByNeed(col.editable, column, model),
|
||||||
optionValues = this.optionValues;
|
optionValues = _.clone(this.optionValues || this.column.get('options'));
|
||||||
|
|
||||||
this.$el.empty();
|
this.$el.empty();
|
||||||
|
|
||||||
if (!_.isArray(optionValues)) throw new TypeError("optionValues must be an array");
|
if (!_.isArray(optionValues)) throw new TypeError("optionValues must be an array");
|
||||||
|
|
||||||
/* Add empty option as Select2 requires any empty '<option><option>' for
|
/*
|
||||||
|
* Add empty option as Select2 requires any empty '<option><option>' for
|
||||||
* some of its functionality to work.
|
* some of its functionality to work.
|
||||||
*/
|
*/
|
||||||
optionValues.unshift([null, null]);
|
optionValues.unshift([null, null]);
|
||||||
@@ -328,8 +328,7 @@
|
|||||||
|
|
||||||
delete this.$select;
|
delete this.$select;
|
||||||
|
|
||||||
this.$select = $("<select>", {tabIndex: -1}),
|
this.$select = $("<select>", {tabIndex: -1}).appendTo(this.$el);
|
||||||
this.$el.append(this.$select);
|
|
||||||
|
|
||||||
for (var i = 0; i < optionValues.length; i++) {
|
for (var i = 0; i < optionValues.length; i++) {
|
||||||
var optionValue = optionValues[i];
|
var optionValue = optionValues[i];
|
||||||
@@ -349,8 +348,12 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Initialize select2 control.
|
// Initialize select2 control.
|
||||||
this.$select.select2(_.defaults(
|
this.$select.select2(
|
||||||
{'disabled': !editable}, col.select2));
|
_.defaults(
|
||||||
|
{'disabled': !editable},
|
||||||
|
col.select2,
|
||||||
|
this.defatuls.select2
|
||||||
|
));
|
||||||
|
|
||||||
this.delegateEvents();
|
this.delegateEvents();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user