1
我的綁定對象有setter和,而在柵格單元變更值,則設置器沒有得到調用。爲什麼?劍道網格更改不會反映在源對象
function PresonDetails(_contactName, _contactTitle, _country, _companyName) {
Object.defineProperties(this, {
"ContactName": {
get: function() {
return this._contactName;
},
set: function (value) {
alert("New ContactName is :" + value)
this._contactName = value; //Setter is not get called when i change the value in grid.
},
enumerable: true,
configurable: true
},
"ContactTitle": {
get: function() {
return this._contactTitle;
},
set: function (value) {
this._contactTitle = value;
},
enumerable: true,
configurable: true
},
"Country": {
get: function() {
return this._country;
},
set: function (value) {
this._country = value;
},
enumerable: true,
configurable: true
},
"CompanyName": {
get: function() {
return this._companyName;
},
set: function (value) {
this._companyName = value;
},
enumerable: true,
configurable: true
}
});
this.ContactName = _contactName;
this.ContactTitle = _contactTitle;
this.Country = _country;
this.CompanyName = _companyName;
}
(function() {
var details = [];
details.push(new PresonDetails("ContactName1", "ContactTitle", "USA", "MICro"));
var $grid = $('#grid');
$grid.kendoGrid({
scrollable: true,
dataSource: details,
groupable: false,
sortable: false,
editable: true,
columns: [{
field: "ContactName",
title: "Contact Name",
width: 200
}, {
field: "ContactTitle",
title: "Contact Title",
width: 250
}, {
field: "CompanyName",
title: "Company Name"
}, {
field: "Country",
width: 150,
}]
});
})();
這裏是demo