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

Edit button does a GET request with a wrong ID

4 Answers 101 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Shane
Top achievements
Rank 1
Shane asked on 07 Oct 2015, 04:22 PM

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?

4 Answers, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 09 Oct 2015, 11:25 AM

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
0
Shane
Top achievements
Rank 1
answered on 09 Oct 2015, 04:05 PM

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!

0
Shane
Top achievements
Rank 1
answered on 20 Oct 2015, 11:27 PM

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.

 

0
Rosen
Telerik team
answered on 23 Oct 2015, 06:38 AM

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
Tags
Grid
Asked by
Shane
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Shane
Top achievements
Rank 1
Share this question
or