Why always post Create action even when click update button?

6 posts, 1 answers
  1. Jason
    Jason avatar
    4 posts
    Member since:
    Jun 2013

    Posted 03 Jul 2013 Link to this post

    I created MVC 3 web application and then convert it to Kendo UI for ASP.NET MVC application. Plz see attached project.

    There is a simple grid on index page, add new item button is on grid toolbar, edit and destroy buttons are in column.

    I could add new row successfully, but when I try to edit existing row, another create action is posted again. Refresh page, two rows in grid. the same thing happens when I try to delete a row.

    Why? Am I missing anything there?

    Please advise.
  2. Answer
    Vladimir Iliev
    Admin
    Vladimir Iliev avatar
    2194 posts

    Posted 05 Jul 2013 Link to this post

    Hi Jason,

     
    After reviewing the provided project it seems that the issue comes from invalid ID of the current record that is added to the Grid - it has ID equal to "0", however the Grid identifies all records with ID equal to "0" as new records. After setting the ID to be equal to "1", the Update action is correctly called:

    private HomeModel GetModel()
    {
        if (Session["HomeModel"] == null)
        {
            Session["HomeModel"] = new HomeModel
            {
                //all records must have model ID > 0
                Records = new List<Record> { new Record { Identity = 1, DateTime3 = DateTime.Now, Number1 = 0, String2 = "first" } }
            };
        }
     
        return (HomeModel)Session["HomeModel"];
    }
    Kind Regards,
    Vladimir Iliev
    Telerik
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. Jason
    Jason avatar
    4 posts
    Member since:
    Jun 2013

    Posted 05 Jul 2013 Link to this post

    Thank you for your help. However, could we recognize it as a bug? For now I only have minified js files otherwise I will fix it myself.

    Thanks again.

  4. Jason
    Jason avatar
    4 posts
    Member since:
    Jun 2013

    Posted 05 Jul 2013 Link to this post

    Thank you for your help. Anyway, could you recognize it as a bug and fix it?
    I only have minified javascript files, otherwsie I will fix it myself.
  5. Vladimir Iliev
    Admin
    Vladimir Iliev avatar
    2194 posts

    Posted 08 Jul 2013 Link to this post

    Hi Jason Li,

     
    As I mention this is the way the dataSource works - current behavior is expected and it's intended. 

    Kind Regards,
    Vladimir Iliev
    Telerik
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  6. Jason
    Jason avatar
    4 posts
    Member since:
    Jun 2013

    Posted 08 Jul 2013 Link to this post

    If you say so...
Back to Top