or
viewModel.selectedSite = ko.observable();
viewModel.editItem =
function
(item) {
viewModel.selectedSite(item);
};
db.get('some-record', function(resp) { });
db.put('some-record', { hello: 'world' }, function(resp) { });
db.post({ hello: 'world' }, function(resp) { });
db.destroy('some-record', { rev: 'abcdef123456789' }, function(resp) { });
The resp variable is a JSON object. Given the above, I have been able to successfully perform all CRUD operations on our database. Now, I would like to implement a Kendo GRID with Popup Editing as here: http://demos.kendoui.com/web/grid/editing-popup.html
$(this._renderTo).kendoGrid({
dataSource: this.ItemsDS,
sortable: true,
pageable: true,
navigatable: true,
editable: true,
save: $.proxy( this.onCellChanged, this ),
columns: [
{ field: "Position.Name", title: "Position", width: 20 },
{ field: "Headcount.value", title: "Headcount", width: 15 },
{ field: "FTE.value", title: "FTE", width: 15 },
{ field: "EmployeeName.value", title: "EmployeeName", width: 50 },
{ field: "JobCode.value", title: "JobCode", width: 20 },
{ field: "JobTitle.value", title: "JobTitle", width: 100 }
]
});
onCellChanged: function (e) {
var isDirty = false;
var fieldName = e.container[0].firstChild.name;
if (!fieldName)
return;
var newValue = e.values[fieldName];
var oldValue = e.model[fieldName]
if (newValue != oldValue) {
var esResults = this.ItemsDS._pristine.EmployeeListResponse.Results;
elemName = fieldName;
// Create the record that will be sent back to TM1
this._employeeUpdates.items.push({
Scenario: esResults.Scenario,
Position: e.model.Position,
Employee: e.model.Employee,
EntityDept: esResults.EntityDept,
ProductLine_s: esResults.ProductLine_s,
Employee_m: { ID: elemName },
Value: newValue
});
e.container.data("oldValue", newValue);
}
},
this.ItemsDS = new kendo.data.DataSource({
transport: {
read: {
url: this._url + "/EmployeeList",
dataType: "json"
},
update: {
url: this._url + "/TM1ViewWrite",
dataType: "xml"
},
parameterMap: $.proxy(this._crudItemDS, this)
},
pageSize: 15,
schema: {
: : : : :
_crudItemDS: function (options, operation) {
if (operation == "update") {
if (this._employeeUpdates) {
return { events: kendo.stringify(this._employeeUpdates) };
};
}
return null;
},