This is a migrated thread and some comments may be shown as answers.
Navigation to Grid MVC
7 Answers 6 Views
This is a migrated thread and some comments may be shown as answers.
Medhanie
Top achievements
Rank 1
Veteran
Medhanie asked on 30 Mar 2020, 04:15 PM

I have Kendo MVC Grid in a view, 

 

I would like to navigate from view to another view that holds Kendo Grid report.

 

 

@Html.ActionLink("Report", "GridList_Read", "Grid")

 

The above code is displaying not formatted plain text content.

 

How do call grid controller from a mvc view?

 

Thank you

7 Answers, 1 is accepted

Sort by
0
Nencho
Telerik team
answered on 01 Apr 2020, 12:12 PM

Hello, Medhanie,

Generally, the call to the controller that you demonstrated seems to be correct. I'm not quite sure about the report that you aim to render. Could you please isolate the issue in a small, simplified runnable example, so we could examine the entire implementation and the issue itself.

Regards,
Nencho
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
Medhanie
Top achievements
Rank 1
Veteran
answered on 28 Apr 2020, 02:32 AM

Hi Nencho;

In my registration page (view) I have the following code

 @Html.ActionLink("Report", "ActionName_Read", "ControllerName")

 

When I click the link I want to display the page where my Kendo Grid is 

The controller for my kendo grid is as follows

public JsonResult ActionName_Read([DataSourceRequest]DataSourceRequest request)
        {

         ....

        // some data is loading here and working fine

         return Json(result, JsonRequestBehavior.AllowGet);
        }

 

When I click the link above, it displays pain data in my page.

 

What is the correct way of calling kendo grid controller and display its view from anywhere in my project?

 

Thank you

0
Nencho
Telerik team
answered on 29 Apr 2020, 12:50 PM

Hello, Medhanie,

You can place the Grid component in a separate Partial view and just use @Html.Partial("GridPartialViewName"). This way, you will load the content in the needed place, and once initiated, the Grid will call its read method.

Check this thread for more information:

https://stackoverflow.com/questions/6060397/calling-html-partial-to-display-a-partial-view-belonging-to-a-different-control

Hope this would help.

Regards,
Nencho
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
Medhanie
Top achievements
Rank 1
Veteran
answered on 30 Apr 2020, 12:46 AM

Hi Nencho;

I am not looking to load my grid in the same page from where I am calling the grid.

Assume, I am in index.cshtml view, and my grid is in gridListView.cshtml view.

 

Being at index.cshtml view page I want to have a link, and when this link is clicked, I want to go to gridListView.cshtml view page.

 

I hope you understand my issue.

 

Let me know

thanks

0
Nencho
Telerik team
answered on 01 May 2020, 12:26 PM

Hello, Medhanie,

Thank you for the additional clarification.

The reason for the experienced issue is that the action link that you use is calling the action, responsible for the data binding of the Grid. That said, you need to load the controller and action that return the View, where the grid is contained. From there one, the Grid will automatically call its Read action to populate with data. Please check this forum thread, where the views navigation is described:

https://stackoverflow.com/questions/18313125/how-to-navigate-among-the-views-in-mvc

Hope this would help.

Regards,
Nencho
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
Medhanie
Top achievements
Rank 1
Veteran
answered on 25 May 2020, 06:33 PM

Hi Nencho;

If you see in my post, I mentioned that I have included both controller name and action name that return the view where the grid is contained.

 

Yes, I am getting all the data in my browser, but my question was, how do I get it formatted.

 

The data is coming as plain text instead of in tabular format like the regular grid format.

 

Please let me as I need this in many section of my project

 

Thank you

0
Nencho
Telerik team
answered on 27 May 2020, 01:42 PM

Hello, Medhanie,

After another revision of the demonstrated implementation, it looks like the name of the View is the same as the read action in the grid. This may be the reason for the problematic behavior. If you want to open another view, and still reuse the current logic in your application, you can change the name of the method, in order to avoid the match of the view name. 

Please give it a try and let me know the results.

Regards,
Nencho
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
Tags
Grid
Asked by
Medhanie
Top achievements
Rank 1
Veteran
Answers by
Nencho
Telerik team
Medhanie
Top achievements
Rank 1
Veteran
Share this question
or