This is a migrated thread and some comments may be shown as answers.
How to add a Grid to my MVC
1 Answer 7 Views
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
Veteran
David asked on 24 Jan 2020, 02:28 PM

I have a CRUD MVC app that is working with no problem. My new project is to add the Telerik grid and batch editing. Well, when I go to add the items, I notice I can straight add the controller as a Telerik form with a grid already made. I thought, wonderful! Now I'm wondering how do I add my links to it that edit and update and details. Do I add the links on the Grid views page? Or do I need to make a separate controller for it? Or do I need to just make a MVC read/write form and add the grid by code? 

 

I'm a C# developer, and I'm not educated well in Json/Ajax/Java so please bear with me. 

1 Answer, 1 is accepted

Sort by
0
Petar
Telerik team
answered on 28 Jan 2020, 09:21 AM

Hi David,

You need to add a separate controller for each of the CRUD operations.

Please check this Batch editing demo. When you scroll down the page to the example's source code. You will see this DataSource definition:

.DataSource(dataSource => dataSource        
        .Ajax()         
        .Batch(true)
        .PageSize(20)
        .ServerOperation(false)                
        .Events(events => events.Error("error_handler"))
        .Model(model => model.Id(p => p.ProductID))
        .Create("Editing_Create", "Grid")
        .Read("Editing_Read", "Grid")
        .Update("Editing_Update", "Grid")
        .Destroy("Editing_Destroy", "Grid")
    )

The marked in yellow lines in the above snippet show us how we define the controllers for each CRUD operation. If you click on the EditingController.cs tab in the linked above Batch editing demo page, you will see the definitions of the different controllers used.

Regards,
Petar
Progress Telerik

Get quickly onboarded and successful with your Telerik UI for ASP.NET MVC with the dedicated Virtual Classroom technical training, available to all active customers.
Tags
Grid
Asked by
David
Top achievements
Rank 1
Veteran
Answers by
Petar
Telerik team
Share this question
or