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

Integrating drag and drop grids in MVC

7 Answers 270 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Matthew
Top achievements
Rank 1
Matthew asked on 30 Dec 2010, 09:00 AM
Hi I'm trying to use a ASP.NET RadGrid in my MVC project.  I followed the documentation to get the RadGrid to display data in my view, but I'd like to be able to use the drag and drop features.  How is the best way to implement it in MVC?  Sorry if this is a repeat question, I did search both the RadGrid and MVC grid forums but couldn't find anything that was what I was looking for.  Any help would be greatly appreciated.  Thanks!

7 Answers, 1 is accepted

Sort by
0
Veli
Telerik team
answered on 05 Jan 2011, 09:20 AM
Hi Matthew,

You can refer to the Integrating RadGrid for ASP.NET AJAX in ASP.NET MVC help topic describing how you can run RadGrid in an MVC project. Note that not all functionality available in RadGrid is guaranteed to work in MVC. For a grid extension designed specifically for MVC, refer to the Telerik Grid Extension for ASP.NET MVC.

Veli
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Matthew
Top achievements
Rank 1
answered on 05 Jan 2011, 07:14 PM
Hi Veli,

I've had a good look at that document and have successfully used the RadGrid in my MVC project.  What I'm interested in is how to organize and incorporate a RadGrid in MVC and use the drap and drop features.  I want to drag and drop between two RadGrids in MVC, but I'm a little at a loss on how to manage that.

Matt
0
Veli
Telerik team
answered on 06 Jan 2011, 06:28 PM
What exactly are you getting? Are you getting any errors (server or client-side) or the grids do not behave as you expect? Can you send us a live URL we can examine? Alternatively, consider opening a regular support ticket where you can attach some small runnable project we can test locally. This will help us exactly identify the issue you are having.

Veli
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Matthew
Top achievements
Rank 1
answered on 25 Jan 2011, 02:41 AM
Sorry perhaps I haven't explained my situation clearly.  I have no code other then the basics of integrating a RadGrid into an MVC View page thats shown in the databinding example for the RadControls documentation. I was hoping to get suggestions or perhaps examples from the support pages on how I could go about utilizing the drag and drop in RadGrid in MVC.
0
Accepted
Veli
Telerik team
answered on 25 Jan 2011, 01:48 PM
Then attached is a basic ASP.NET MVC application demonstrating how you can use RadGrid's Rows drag-and-drop functionality. You need to reference the Telerik.Web.UI assembly in the solution and you can run it. You can use the client-side items drag-and-drop functionality of RadGrid, but you cannot postback on drag as you would do in a normal ASP.NET page. There is no page and control life cycle in ASP.NET MVC as required in standard ASP.NET. You cannot use server-side grid events. In fact, you will get a javascript error if you try to drag and drop an item without canceling the event. This error indicates there is no __doPostBack() method you can use at all.

That said, you need to cancel the postback using the client-side OnRowDropping event of RadGrid. You can get the dragged items, destination data item, id, index or target HTML element inside the same event handler. You have all this data available on the client and you can use it to implement your business logic.

Check it out.

Greetings,
Veli
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Matthew
Top achievements
Rank 1
answered on 15 Apr 2011, 06:40 AM
Thanks Veli that did the trick.  I used the OnRowDropping event and used the script it called to grab the selected rows, the destination grid, and the source grid, and stuck them all into hidden fields in a form.  I then called a submit and got the data to a controller for processing.
0
Sri
Top achievements
Rank 1
answered on 12 Apr 2012, 04:33 PM
I am in the same boat.
Can you send me an example with the complete code with mvc3 using razor? I am unable to get it to work.
Tags
Grid
Asked by
Matthew
Top achievements
Rank 1
Answers by
Veli
Telerik team
Matthew
Top achievements
Rank 1
Sri
Top achievements
Rank 1
Share this question
or