So I have a myViewModel.js that I read in. which has the datasource, but I doesn't seem to call destroy.
Also the kendo.data.ObservableObject.fn.init.apply(that, []); confuses me. I wish there were more mvvm examples that are read in from a js file.
in my html I got:
Also the kendo.data.ObservableObject.fn.init.apply(that, []); confuses me. I wish there were more mvvm examples that are read in from a js file.
in my html I got:
$(
"#dgGrid"
).kendoGrid({
groupable:
false
,
sortable:
true
,
editable:
"inline"
,
columns: [
{
field:
"accountId"
,
title:
"User #"
,
width:
"50px"
},
{
field:
"currentAmt"
,
title:
"Amount"
,
width:
"100px"
},
{ command: [{ name:
"destroy"
, template:
"<div class='k-button'><span class='k-icon k-delete'></span></div>"
}], title:
" "
, width: 40 }
]
});
<
div
id
=
"dgGrid"
data-role
=
"grid"
style
=
"width:340px; font-size:9px; height:250px"
data-bind
=
"source: userAccountsDataSource"
>
<
style
type
=
"text/css"
>
.k-grid tbody .k-button {
min-width: 12px;
width: 30px;
}
</
style
>
</
div
>
(
function
(global) {
var
FlossViewModel,
app = global.app = global.app || {};
FlossViewModel = kendo.data.ObservableObject.extend({
acountId:
""
,
accountNick:
""
,
newbcId:
"q"
,
userId:
"0"
,
checkDate:
""
,
errorMsg:
""
,
accountsVis:
true
,
userAccountsDataSource:
""
,
refreshAccount:
function
(){
this
.populateAccounts();
},
populateAccounts:
function
(){
var
that =
this
;
// kendo.data.ObservableObject.fn.init.apply(that, []);
var
dataSourceaa =
new
kendo.data.DataSource({
transport: {
read: {
type:
"GET"
,
dataType:
"jsonp"
,
url:
'/api/FlossAccount/'
},
destroy: {
type:
"DELETE"
,
url:
function
(options) {
return
'/api/FlossAccount/1'
;
},
dataType:
"jsonp"
,
data: {
''
:
'333'
}, //i'm just putting any data for now
cache:
false
},
parameterMap:
function
(options, operation) {
if
(operation !==
"read"
&& options.models) {
return
{ models: kendo.stringify(options.models) };
}
}
},
error:
function
(e) {
that.set(
"errorMsg"
,
"Error: Check Connection "
);
dataSourceaa.cancelChanges();
}
});
that.set(
"userAccountsDataSource"
, dataSourceaa);
dataSourceaa.read();
// this.set("userAccountsDataSource", dataSourceaa);
},
.....
});
app.flossService = {
viewModel:
new
FlossViewModel()
};
})(window);