I am trying to integrate select2 in backgrid.js. Backgridjs has extension support for select2 and the code for that is
{
name: "gender",
cell: Backgrid.SelectCell.extend({
optionValues: [["Male", "m"], ["Female", "f"]]
}),
label: "Gender (SelectCell)"
}
so based on this i tried something like the below since i have to load values to select2 box from the server
var FetchSecurities = Backbone.Model.extend({
url : Hexgen.getContextPath("/referencedata/securities")
});
var fetchSecurities = new FetchSecurities();
{
name: "security",
label: "Security",
cell: Backgrid.Extension.Select2Cell.extend({
optionValues: fetchSecurities.fetch({
success : function() {
for(var objectPlace in fetchSecurities.attributes) {
[[fetchSecurities.attributes[objectPlace].security],[fetchSecurities.attributes[objectPlace].security]];
}
}
}),
})
}
but i get this exception, I am sure i make mistake when constructing the value for the select2 box but don't know how to fix it, Please help me to get it done.
Uncaught TypeError: 'optionValues' must be of type {Array.<Array>|Array.<{name: string, values: Array.<Array>}>}