This is a migrated thread and some comments may be shown as answers.

popup editing does not work Help Me Please

1 Answer 226 Views
Window
This is a migrated thread and some comments may be shown as answers.
Sayed
Top achievements
Rank 1
Sayed asked on 30 Mar 2012, 02:21 AM
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  
$(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

1 Answer, 1 is accepted

Sort by
0
Alexander Valchev
Telerik team
answered on 30 Mar 2012, 10:27 AM
Hi Sayed,

Most of the examples in the github page use version 2011.3.1129, which does not support popup editing mode. I believe that is the reason of the problem. Could you please confirm that you are using the latest official release ( 2012.1.322 ) in your project.

Greetings,
Alexander Valchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Window
Asked by
Sayed
Top achievements
Rank 1
Answers by
Alexander Valchev
Telerik team
Share this question
or