Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
170
igGrid - Not rendering when returning multiple partial views.
posted

I need to return multiple (two) partial views as an ActionResult from the controller. The first view contains general form elements and the second view contains the igGrid. Since I need to return multiple partialviews,  I was able to create a controller action that returned a JSON object containing the rendering for my two partial views. I also developed a helper method that render each partial view into a string (which is returned in the JSON object).

The problem is that while my first view is getting rendered just fine and the view containing the grid is not rendering. Any ideas how can I accomplish this?

Here's the helper method:

public static string RenderPartialView(ViewDataDictionary viewData, ControllerContext context, TempDataDictionary tempData, string viewName, object model)
{
viewData.Model = model;

using (System.IO.StringWriter writer = new System.IO.StringWriter())
{
ViewEngineResult viewResult = ViewEngines.Engines.FindPartialView(context, viewName);
ViewContext viewContext = new ViewContext(context, viewResult.View, viewData, tempData, writer);
viewResult.View.Render(viewContext, writer);

return writer.GetStringBuilder().ToString();
}
}

Here's the code grid defination:

@(Html.Infragistics()
.Grid(Model.MessageQueueRows)
.ID("grid")
.Width("100%")
.PrimaryKey("MessageQId")
.AutoGenerateColumns(false)
.AutoGenerateLayouts(false)
.Columns(column =>
{
column.For(x => x.LastName).HeaderText("Last Name").Width("200");
column.For(x => x.FirstName).HeaderText("First Name").Width("200");
column.For(x => x.CallPhone).HeaderText("Phone").Width("200");
column.For(x => x.TextPhone).HeaderText("Text Phone #").Width("200");
column.For(x => x.PersonId).HeaderText("ID").Width("200");
column.For(x => x.Group).HeaderText("Group").Width("200");
column.For(x => x.Subgroup).HeaderText("Subgroup").Width("200");
column.For(x => x.Sent).HeaderText("Sent Date").Width("200");
})

.Features(features =>
{
features.Sorting().Mode(SortingMode.Single).Type(OpType.Local).ApplyColumnCss(false).ColumnSettings(cs =>
{
cs.ColumnSetting().ColumnKey(Model.ColumnKey).AllowSorting(true).CurrentSortDirection(Model.Direction);
});
features.Paging().Type(OpType.Local).PageSize(Model.PgSize).CurrentPageIndex(Model.PageIndex);
features.Resizing();
})

.DataSource(Model.MessageQueueRows)
.DataBind()
.Render()
)

Parents
  • 29417
    Offline posted

    Hello voicemetrix , 

    Thank you for posting in our forum. 

    In what manner do you render the data from the JSON?

    In general  you could directly return an MvcHtmlString from your action which can be directly rendered on the view.

    I’ve attached a sample with a similar setup for your reference. Let me know if you’re aiming to achieve something similar.

     

    Best Regards,

    Maya Kirova

    Infragistics, Inc.

    http://es.infragistics.com/support 

     

                                                                                      

    Grid_PartialViews.zip
Reply Children