Edit button does a GET request with a wrong ID

5 posts, 0 answers
  1. Shane
    Shane avatar
    5 posts
    Member since:
    Sep 2015

    Posted 07 Oct 2015 Link to this post

    Hi.  I have 2 screen with a Telerik MVC grid.  First one is for Orders and second one for OrderDetails.  I use server binding.

    The first one works fine.  It shows Orders data in the grid.  Each row has a Details button and when I click on the button, the second screen shows up with the OrderDetails data of the Order data you selected  in the grid.  Here each row has a Edit button that is supposed to perform inline editing.

    At this point, the URL is http://myweb.com/Order/Details/123.  123 is the OrderId in the Orders table.

    The problem happens when I click on Edit button for the row data.  It does a GET request with OrderDetailId automatically.  The page expects OrderId not OrderDetailId.

    So, at this point, the page expects http://myweb.com/Order/Details/##OrderId## but the grid does http://myweb.com/Order/Details/##OrderDetailId##.

    How should I handle this case?  Could I manage what URL format the grid uses for the Edit button?

  2. Rosen
    Admin
    Rosen avatar
    3234 posts

    Posted 09 Oct 2015 Link to this post

    Hello Shinichi,

    Indeed, when Grid item is set into edit mode its id will be appended to the edit URL. However, the current URL parameters will be also persisted. I have created a small sample project which tries to re-create the issue using the described scenario. Please take a look maybe I'm missing something obvious.

    Regards,
    Rosen
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Shane
    Shane avatar
    5 posts
    Member since:
    Sep 2015

    Posted 09 Oct 2015 in reply to Rosen Link to this post

    Hi Rosen,

    THank you for your reply.  Running your code, yes it works.  But my code doesn't.

    When OrderId=1 & OrderDetailId=3, your Detail button's GET request ​is:

        /Home/Order_Details/1?grid-mode=edit&OrderDetailID=3

    Mine is:

       /Home/Order_Details/3

    But now I know it should work if I do things correctly, so I will try to find the difference between yours and mine.  Thank you!

  5. Shane
    Shane avatar
    5 posts
    Member since:
    Sep 2015

    Posted 20 Oct 2015 in reply to Shane Link to this post

    Hi Rosen,

    I'm back to this problem.  I could reproduce the problem with your code as well.  Please see the attachment (only modified files are attached because of 2MB limit. Please also see your original attachment above.)

    The difference is only at the primary key names (Order.OrderID => Order.ID / Order_Detail.Order_DetailID => Order_Detail.ID). 

    It seems the problem happens when the primary keys are the same name, for instance "Id", for both Order & OrderDetail tables.

     

  6. Rosen
    Admin
    Rosen avatar
    3234 posts

    Posted 23 Oct 2015 Link to this post

    Hello Shane,

     

    This is expected as the route key name is the same as the one set in the route. There is a route parameter in default route which is named id and in the grid you have configure the link to set this route parameter to be bound to the value of current record id. Thus, it gets populated removing the previous value, which is the original id for the order. In order to make this work you should configure two separate route parameters - for example as shown in my original sample project.

     

    Regards,
    Rosen
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top
UI for ASP.NET MVC is VS 2017 Ready