当我提交移动表单时,我会收到回复并保存#34;但是它不会保存到我的数据库中。使用telerik appbuilder。我似乎无法在网上找到任何资源,所以任何帮助都会非常感激。我也不知道从哪里开始学习针对Web服务的kendo.ui。任何书籍或链接都很棒。
'use strict';
app.home = kendo.observable({
onShow: function() {},
afterShow: function() {}
});
app.localization.registerView('home');
// START_CUSTOM_CODE_home
// Add custom code here. For more information about custom code, see http://docs.telerik.com/platform/screenbuilder/troubleshooting/how-to-keep-custom-code-changes
// END_CUSTOM_CODE_home
(function(parent) {
var
/// start global model properties
/// end global model properties
dataProvider = app.data.jsonProvider,
dataSourceOptions = {
type: 'jsonp',
transport: {
//typeName: 'registration',
read: {
url: dataProvider.url
},
create: {
url: dataProvider.url
}
},
schema:{
model: {
id: "id",
fields: {
id: { type: "number"},
course: { type: "number" },
firstname: { type: "string" },
lastname: { type: "string" },
studentemail: { type: "string" }
}
}
},
error: function(e) {
if (e.xhr) {
alert(JSON.stringify(e.xhr));
}
},
},
homeModel = kendo.observable({
submit: function() {
var addFormData = parent.get('addFormData'),
addModel = {};
app.mobileApp.showLoading();
function saveModel(data) {
/// start add form data save
addModel.studentemail = addFormData.studentemail;
addModel.lastname = addFormData.lastname;
addModel.firstname = addFormData.firstname;
addModel.course = addFormData.course;
/// end add form data save
var dataSource = new kendo.data.DataSource(dataSourceOptions);
dataSource.add(addModel);
dataSource.one('change', function(e) {
// datasource operation finished
app.mobileApp.hideLoading();
app.showNotification('Saved');
});
dataSource.one('error', function(error) {
showErrorMessage(error.xhr || error);
});
dataSource.sync();
};
function showErrorMessage(error) {
alert('code: ' + error.code + '\n' + 'message: ' + error.message + '\n');
app.mobileApp.hideLoading();
}
/// start add form save
/// end add form save
/// start add form save handler
saveModel();
/// end add form save handler
},
/// start add model functions
/// end add model functions
cancel: function() {
/// start add model cancel
/// end add model cancel
}
/// start add model properties
/// end add model properties
});
/// start form functions
/// end form functions
parent.set('onShow', function _onShow() {
var that = parent;
that.set('addFormData', {
studentemail: '',
lastname: '',
firstname: '',
course: '',
/// start add form data init
/// end add form data init
});
/// start add form show
/// end add form show
});
parent.set('homeModel', homeModel);
})(app.home);
// START_CUSTOM_CODE_homeModel
// Add custom code here. For more information about custom code, see http://docs.telerik.com/platform/screenbuilder/troubleshooting/how-to-keep-custom-code-changes
// END_CUSTOM_CODE_homeModel