Backgrid example code: This is the code given in the backgrid website, similarly i have to get the values from the database to populate the select2cell option values inside the grid
var data = new Backbone.Collection([{number: 5, another: 1}]);
// Just like SelectCell, Select2Cell supports option lists and groups
var numbers = [{name: 10, values: [
[1, 1], [2, 2], [3, 3], [4, 4], [5, 5],
[6, 6], [7, 7], [8, 8], [9, 9], [10, 10]
]}];
var MySelect2Cell = Backgrid.Extension.Select2Cell.extend({
select2Options: {
// any options specific to `select2` goes here`enter code here`
},
optionValues: numbers
});
var grid = new Backgrid.Grid({
columns: [{
name: "number",
cell: MySelect2Cell
},
{
name: "another",
cell: MySelect2Cell
}],
collection: data
});
$("#select2-cell-example-result").append(grid.render().el);
Like this i have to get the options values from the database
Here are some examples from the official documentation.