or
Hi all,
i have refered video(Get Started With The Kendo UI DataSource) provided
by kendo team and i have tried to do the same, but on click of create-click button create: {} section of datasource is not called. as per video on click of create
button create:{} section will be called automatically.
please find the code example below.
$(document).ready(function () {
// --------------------------------------------------------------------------------
// DataTable Section
// --------------------------------------------------------------------------------
clinetDataSource = new kendo.data.DataSource({
batch: true,
editable:true,
transport: {
create: {
url: _WebServiceAddress + "Client/Client",
contentType: "application/json; charset=utf-8",
type: "POST"
},
read: {
url: _WebServiceAddress + "Client/ClientTable",
datatype: "odata"
},
parameterMap: function (data, operation) {
if (operation !== "read" && data.models) {
return { models: kendo.stringify(data.models) };
}
else if (operation != "read") {
// web service method parameters need to be send as JSON. The Create, Update and Destroy methods have a "products" parameter.
return JSON.stringify(data)
}
}
},
schema: {
model: clientModel
},
pageSize: 10,
batch: true
});
var clientModel = kendo.data.Model.define({
id: "RecId",
fields: {
RecId: { editable: false, nullable: true },
ClientName: { type: "string" },
ResponsibleName: { type: "string" },
IsActive: { type: "boolean" }
}
});
_Table= $("#tableClientDetails").kendoGrid({
columns: [
{field: "RecId", title: "Action", width: 50,
template: '<img class="buttonEditTable" id="buttonEditTable_#=RecId#" alt="#= RecId #" src="/Desktop/Global/Images/DataTable/Edit.png"/> '
},
{ field: "ClientName", title: "Name" },
{ field: "ResponsibleName", title: "Contact Person" },
{ field: "IActive", title: "Active", width:100,
template: '<input class="checkboxActive" id="checkbox_#=RecId#" type="checkbox" #= IsActive ? "checked=checked" : "" # ></input>'
}
],
dataSource: clinetDataSource,
groupable: true,
filterable: true,
sortable: true,
pageable: true,
scrollable:false,
editable: true
});
});
$("#create-client").click(function () {
clinetDataSource.add({
Address: $("#textareaAddress").val(),
ResponsibleEmailAddress: $("#fieldContactPersonEmailId").val(),
Telephone: $("#fieldTelephone").val(),
City: $("#fieldCity").val(),
State: $("#selectState").find(':selected').text(),
Country: $("#selectCountry").find(':selected').text()
});
clinetDataSource.sync();
});
please advice. how create:{}/update:{} will be called.
Thanks,
Shankar
<ul data-role="listview" data-style="inset"> <li> <input name="signinEmail" type="email" id="signinEmail" value="" placeholder="Email Address"/> </li> <li> <input name="signinPassword" type="password" id="signinPassword" value="" placeholder="Password"/> </li> </ul>
listmessages view has a listView widget to display all the messages (the datasource), when one is selected, they are directed to the viewmessage remote view which will display all the data for the selected ID. listmessages ). viewmessage view and would prefer to access the relevant dataSource id to display the selected data.<div data-role="view" data-title="Mobile" id="listmessages" data-init="listMessagesInit"> <h2>Customer Messages</h2> <p><?php echo $unread_messages . ' - unread messages'; ?></p> <ul id="message_list"></ul> </div> <script id="message_list_template" type="text/x-kendo-template"><a href=""><div style="float:left; width:150px; height: 50px" class="isnew_#= isnew #">#= customer_name #<br />#= created #</div><div style="height: 50px"id="message_#= id #" class="isnew_#= isnew #">#= message #</div></a></script><script> function listMessagesInit(){ var dataSource = new kendo.data.DataSource({ transport: { read: "/messages/data", dataType: "json", update: { url: function() { //where id is a global variable var url = "/messages/markasread/" + id + "/" + read; return url; }, type: "POST", dataType: "json" //other configurations }, destroy: { url: function() { //where id is a global variable var delurl = "/messages/delete/" + id; return delurl; }, type: "DELETE", dataType: "json" } }, schema: { model: { id: "id", fields: { created: { type: "string" }, message: { type: "string" }, customer_name: { type: "string" }, isnew: { type: "string" } } } } }); $("#message_list").kendoMobileListView({ dataSource: dataSource, //pullToRefresh: true, //appendOnRefresh: true, style: "inset", click: function(e) { var id = e.dataItem.id; var selected = dataSource.get(id); window.kendoMobileApplication.navigate("/messages/view/" + id); }, template: $("#message_list_template").text() }); } </script> <style> #listmessages div.isnew_1 {font-weight:bold} #listmessages div.isnew_0 {font-weight:normal} </style> <div data-role="view" data-title="Mobile" id="viewmessage" data-init="viewMessageInit"> <h2>Message</h2> <p>Date: <?=$message->message->created?></p> <p>From: <?=$message->message->customer_name?></p> <p>Email: <a href="mailto:<?=$message->message->email?>" target="_blank"><?=$message->message->email?></a></p> <p>Telephone: <?=$message->message->customer_telephone?></p> <p>Location IP:<?=$message->message->ip?></p> <div data-role="scroller"> <p><?=$message->message->message?></p> </div> <?php $read_text = ($message->message->isnew == 1 ? 'Mark as read' : 'Mark as unread'); ?> <?php $read = ($message->message->isnew == 1 ? 0 : 1); ?> <p><a data-align="left" data-role="button" id="markasread" ><?=$read_text?></a> <a data-align="right" data-role="button" id="delete">Delete</a></p> </div> <script> function viewMessageInit(){ //var selected is defined in previous view - how to access this? $("#markasread").click(function(){ selected.set("isnew", read); dataSource.sync(); }); $("#delete").click(function(){ dataSource.remove(selected); dataSource.sync(); }); } </script>that.data = function(data) { var record, getter, idx, length, modelInstance = new that.model(); data = dataFunction(data); if( isEmptyObject(data) ) // Added this fix to prevent errors if no data was returned return {}; if (!isEmptyObject(getters) ) { for (idx = 0, length = data.length; idx < length; idx++) { record = data[idx]; for (getter in getters) { record[getter] = modelInstance._parse(getter, getters[getter](record)); } } } return data;}<ul id="items" data-bind="source: items"></ul>var data = activitiesSource.view(), selected = $.map(this.select(), function (item) { return data[$(item).index()]; });viewModel.set("selectedItem", selected);<div class="js-item-details"> <h2 data-bind="text: selectedItem.Title"></h2> <h3 data-bind="text: selectedItem.Descritpion"></h3></div>