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

Deleting a row on the grid

6 Answers 231 Views
Grid
This is a migrated thread and some comments may be shown as answers.
MarkBr
Top achievements
Rank 2
MarkBr asked on 21 Apr 2014, 06:00 AM
Hi,

View, Insert, update work fine however I cannot get the delete to work exception [The instance is transient]. I copied the code from an example.

See attached file.

Thanks
Mark Brewer

6 Answers, 1 is accepted

Sort by
0
Vladimir Iliev
Telerik team
answered on 23 Apr 2014, 06:43 AM
Hi Mark,

From the provided information it seems that you are trying to delete object that is not part of the context due to the way you are creating new Customer from the received ViewModel. In current case I would suggest to use the approach demonstrated in the following help topic:

Regards,
Vladimir Iliev
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
MarkBr
Top achievements
Rank 2
answered on 23 Apr 2014, 01:09 PM
I created the same table as per the example you referenced and it work fine except it is not using Kendo Grid with Ajax. I took the original code from an example and all works well except the delete. As I an new to asp.net mvc and Kendo I am a bit lost. I have googled quite a bit to try to find other examples and have failed to find any others.

Can you point me to an example using Fluent OpenAccess, UI for Asp.Net MVC?
0
Vladimir Iliev
Telerik team
answered on 24 Apr 2014, 11:27 AM
Hi Mark,

Could you please provide runable project where the issue is reproduced? This would help us pinpoint the exact reason for this behavior.

Kind Regards,
Vladimir Iliev
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
MarkBr
Top achievements
Rank 2
answered on 07 May 2014, 10:59 AM
Hi Vladimir,

Please find attached solution. I had to remove all the binaries and Kendo scripts.

Best regards,
Mark Brewer
0
Accepted
Daniel
Telerik team
answered on 09 May 2014, 10:49 AM
Hello Mark,

The exception is thrown because the object used for the Delete method is not attached to the context. You should use an attached object for the Delete method e.g.
public ActionResult Customers_Destroy([DataSourceRequest] DataSourceRequest request, Customer customer)
{
    if (ModelState.IsValid)
    {
        using (var vwVortex = new FluentModel())
        {
 
            var entity = vwVortex.AttachCopy(customer);                   
            vwVortex.Delete(customer);
            vwVortex.SaveChanges();
        }


Regards,
Daniel
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
MarkBr
Top achievements
Rank 2
answered on 10 May 2014, 09:51 AM
Sorted thanks Daniel
Tags
Grid
Asked by
MarkBr
Top achievements
Rank 2
Answers by
Vladimir Iliev
Telerik team
MarkBr
Top achievements
Rank 2
Daniel
Telerik team
Share this question
or