Hi
i tries to use popup editing using the asp.net examples https://github.com/telerik/kendo-examples-asp-net
by changing the editor option to "popup" but it does not response and continue use inline editing
and also when i try to create new on using the below code it doesn't work
script code
web service code
thanks
i tries to use popup editing using the asp.net examples https://github.com/telerik/kendo-examples-asp-net
by changing the editor option to "popup" but it does not response and continue use inline editing
and also when i try to create new on using the below code it doesn't work
script code
$(document).ready(function () {
$("#mygrid").kendoGrid({
dataSource: {
schema: {
data: 'd',
model: {
id: "Id",
fields: {
Id: { type: "number" },
FirstName: { type: "string" },
LastName: { type: "string" },
City: { type: "string" },
BirthDate: { type: "date" }
}
}
},
transport: {
create: {
url: "../Webservices/KendoService.asmx/CreateAds", //specify the URL which should create new records. This is the Create method of the Products.asmx service.
contentType: "application/json; charset=utf-8", // tells the web service to serialize JSON
type: "POST" //use HTTP POST request as the default GET is not allowed for ASMX
},
read: {
url: "../Webservices/KendoService.asmx/ReadAds", //specify the URL which data should return the records. This is the Read method of the Products.asmx service.
contentType: "application/json; charset=utf-8", // tells the web service to serialize JSON
type: "POST" //use HTTP POST request as the default GET is not allowed for ASMX
},
update: {
url: "../Webservices/KendoService.asmx/UpdateAds", //specify the URL from which should update the records. This is the Update method of the Products.asmx service.
contentType: "application/json; charset=utf-8", // tells the web service to serialize JSON
type: "POST" //use HTTP POST request as the default GET is not allowed for ASMX
},
destroy: {
url: "../Webservices/KendoService.asmx/DestroyAds", //specify the URL which should destroy records. This is the Destroy method of the Products.asmx service.
contentType: "application/json; charset=utf-8", // tells the web service to serialize JSON
type: "POST" //use HTTP POST request as the default GET is not allowed for ASMX
},
parameterMap: function (data, operation) {
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({ products: data.models })
}
}
},
pageSize: 10
},
pageable: true,
height: 400,
toolbar: ["create"],
columns: [
{ field: "Id", width: "60px" },
{ field: "FirstName", title: "First Name" },
{ field: "LastName", title: "Last Name" },
{ field: "City" },
{ field: "BirthDate", template: '#= kendo.toString(BirthDate,"MM/dd/yyyy") #' },
{ command: [
{ name: "edit", text: "CustomEdit" }, // sets the text of the Edit button
{name: "destroy", text: "Destroy"} // sets the text of the "Delete" button
],
// sets the title and the width of the commands column
title: " ",
width: "300px"
}
],
editable: "popup",
//changes the text of the "Update" and "Cancel" buttons in the inline edit mode
edit: function () {
var updateBtnTxt = "CustomUpdate",
cancelBtnTxt = "CustomCancel",
curr_container = this._editContainer; //selects the current edit container
//sets the text of the "Update" button
$(curr_container).find("a.k-grid-update").text(updateBtnTxt);
//sets the text of the "Cancel" button
$(curr_container).find("a.k-grid-cancel").text(cancelBtnTxt);
}
});
});
web service code
/// <
summary
>
/// Creates new products by inserting the data posted by the Kendo Grid in the database.
/// </
summary
>
/// <
param
name
=
"products"
>The products created by the user.</
param
>
/// <
returns
>The inserted products so the Kendo Grid is aware of the database generated ProductID</
returns
>
[WebMethod]
public IEnumerable<
TempJson
> CreateAds(IEnumerable<
TempJson
> products)
{
var result = new List<
JobHistory
>();
JobHistoryDB sdb = new JobHistoryDB();
JobHistoryCollection myCollection = new JobHistoryCollection();
List<
TempJson
> returned = new List<
TempJson
>();
foreach (TempJson j in products)
{
JobHistory my = new JobHistory();
my.Approved = true;
my.CompanyID = 1;
my.CompanyName = "";
my.End = DateTime.Parse(j.BirthDate);
my.Start = DateTime.Parse(j.BirthDate);
my.JobTitle = j.FirstName;
myCollection.Add(my);
}
sdb.Insert(myCollection);
if (sdb.Insert(myCollection) > 0)
{
foreach (JobHistory j in myCollection)
{
TempJson mj = new TempJson();
mj.Id = j.JobHistoryID;
mj.FirstName = j.JobTitle;
mj.LastName = j.CompanyName;
mj.BirthDate = j.Start.ToShortDateString();
returned.Add(mj);
}
}
return returned;
}
/// <
summary
>
/// Reads the available products to provide data for the Kendo Grid
/// </
summary
>
/// <
returns
>All available products</
returns
>
[WebMethod]
public IEnumerable<
TempJson
> ReadAds()
{
JobHistoryDB sdb = new JobHistoryDB();
JobHistoryCollection myCollection = new JobHistoryCollection();
List<
TempJson
> returned = new List<
TempJson
>();
foreach (JobHistory j in sdb.GetAll())
{
TempJson mj = new TempJson();
mj.Id = j.JobHistoryID;
mj.FirstName = j.JobTitle;
mj.LastName = j.CompanyName;
mj.BirthDate = j.Start.ToShortDateString();
returned.Add(mj);
}
return returned;
}
/// <
summary
>
/// Updates existing products by updating the database with the data posted by the Kendo Grid.
/// </
summary
>
/// <
param
name
=
"products"
>The products updated by the user</
param
>
[WebMethod]
public void UpdateAds(IEnumerable<
TempJson
> products)
{
JobHistoryDB sdb = new JobHistoryDB();
JobHistoryCollection myCollection = new JobHistoryCollection();
foreach (TempJson j in products)
{
JobHistory my = sdb.GetByPK_JobHistory(j.Id)[0];
my.End = DateTime.Parse(j.BirthDate);
my.JobTitle = j.FirstName;
myCollection.Add(my);
}
sdb.Update(myCollection);
}
/// <
summary
>
/// Destroys existing products by deleting them from the database.
/// </
summary
>
/// <
param
name
=
"products"
>The products deleted by the user</
param
>
[WebMethod]
public void DestroyAds(IEnumerable<
TempJson
> products)
{
JobHistoryDB sdb = new JobHistoryDB();
JobHistoryCollection myCollection = new JobHistoryCollection();
foreach (TempJson j in products)
{
JobHistory my = sdb.GetByPK_JobHistory(j.Id)[0];
myCollection.Add(my);
}
sdb.Delete(myCollection);
}
}
public class TempJson
{
public int Id { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string City { get; set; }
public string BirthDate { get; set; }
}
thanks