Backgrid 示例代码: 这是 backgrid 网站中给出的代码,同样我必须从数据库中获取值以填充网格内的 select2cell 选项值
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);
像这样我必须从数据库中获取选项值