Here is my grid.js that populates the data from database.I got all codes set and everything is working fine. After the editable field is clicked i want that specific data to be passed to the backend. How can i achieve that?
As it is an example from here, i didnt create the JSFIDDLE
The documentation says BackGrid.CellEditor and some codes says this.listenTo()
Unfortunately, I dont know how to embed this into this code.
Thanks for the help.
var Territory = Backbone.Model.extend({});
var PageableTerritories = Backbone.PageableCollection.extend({
model: Territory,
// url: "./json/territories.json",
url: "./api.php",
state: {
pageSize: 15
},
mode: "client" // page entirely on the client side
});
var pageableTerritories = new PageableTerritories();
var columns = [{
name: "id", // The key of the model attribute
label: "ID", // The name to display in the header
editable: false, // By default every cell in a column is editable, but *ID* shouldn't be
// Defines a cell type, and ID is displayed as an integer without the ',' separating 1000s.
cell: Backgrid.IntegerCell.extend({
orderSeparator: ''
})
}, {
name: "name",
label: "Name",
// The cell type can be a reference of a Backgrid.Cell subclass, any Backgrid.Cell subclass instances like *id* above, or a string
cell: "string" // This is converted to "StringCell" and a corresponding class in the Backgrid package namespace is looked up
}, {
name: "pop",
label: "Population",
cell: "integer" // An integer cell is a number cell that displays humanized integers
}, {
name: "percentage",
label: "% of World Population",
cell: "number" // A cell type for floating point value, defaults to have a precision 2 decimal numbers
}, {
name: "date",
label: "Date",
cell: "date" // A cell type for floating point value, defaults to have a precision 2 decimal numbers
}, {
name: "url",
label: "URL",
cell: "uri" // Renders the value in an HTML anchor element
}];
// Set up a grid to use the pageable collection
var pageableGrid = new Backgrid.Grid({
columns: [{
// enable the select-all extension
name: "",
cell: "select-row",
headerCell: "select-all"
}].concat(columns),
collection: pageableTerritories
});
// Render the grid
var $example2 = $("#example-1-result");
$example2.append(pageableGrid.render().el)
// Initialize the paginator
var paginator = new Backgrid.Extension.Paginator({
collection: pageableTerritories
});
// Render the paginator
$example2.after(paginator.render().el);
// Initialize a client-side filter to filter on the client
// mode pageable collection's cache.
//var filter = new Backgrid.Extension.ClientSideFilter({
// collection: pageableTerritories,
// fields: ['name']
//});
// Render the filter
//$example2.before(filter.render().el);
// Add some space to the filter and move it to the right
//$(filter.el).css({float: "right", margin: "20px"});
// Fetch some data
pageableTerritories.fetch({reset: true});
I created downloading a backbone template. I share the full project file here Sharing full project folder Dropbox Link