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

[Solved] Create Window using a Partial View

2 Answers 450 Views
Window
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Sydney
Top achievements
Rank 1
Sydney asked on 10 Feb 2011, 01:24 AM
The documentation on creating a window from a partial view doesn't make sense to me and it's not clearly described anywhere that I can find.   Seems like I have to call some controller action, but in the example, the only controller action does not correspond to the "AjaxView" and "Window" parameters passed to the LoadContentFrom method.  

@(Html.Telerik().Window()
   
.Name("Window")
   
.LoadContentFrom("AjaxView", "Window")
   
.Buttons(buttons => buttons.Refresh().Maximize().Close())
   
.Width(450)    
   
.Draggable(true)
)

In any case, if I have a partial view, I don't want to create a controller action just to get it - I'd like to be able to do something like this:

@{ Html.Telerik().Window()
        .Name("Window")
        .Draggable(true)
        .Modal(false)
        .Buttons(b => b.Close())
        .Content(@<text>
                 @Html.RenderPartial("mypartial", ViewData)
            </text>)
        .Width(500)
        .Height(500)
        .Visible(false)
        .Render();
}



Is that possible?  If not, could we get an explanation of how LoadContentFrom is supposed to work to load a partial?

Thanks.

2 Answers, 1 is accepted

Sort by
0
SUVODEEP
Top achievements
Rank 1
answered on 13 Aug 2011, 04:34 PM
Hi , I was searching for a same issue
In my case I have used LoadContentFrom
What I have done is
  •  <%  Html.Telerik().Window().Name("LogOnWindow").LoadContentFrom("TestGrid", "TestGrid").Draggable(true).Height(300).Width(300).Resizable().Title("Log In").Visible(true).Render(); in view page
  • In my TestGrid Controller , there is an action TestGrid , and have created a partial view wrt to TestGrid action. which shows a grid

My partial View
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<IEnumerable<GridWithWindow.Controllers.GridData>>" %>

 <%= Html.Telerik().Grid(Model)
                                           .Name("Grid")
                                           .DataKeys(m => m.Add(key => key.FirstColumn))
                                           .Columns(columns =>
                                           {

                                               //    columns.AutoGenerate(true);
                                               columns.Bound(o => o.FirstColumn).Hidden();
                                               columns.Bound(o => o.SecondColumn).Title("RAJ");
                                               columns.Bound(o => o.ThirdColumn).Title("RAJ222");
                                               columns.Bound(o => o.ThirdColumn).Title("RAJ222");

                                           })                                                   
                                                   .Pageable()
                                                   .EnableCustomBinding(true)
                                                   .Sortable()
                                                   .Filterable()
                                                   .Groupable()
                                                   .Selectable()

    %>   
MY CONTROLLER ACTION

 public IEnumerable<GridData> GetGridData()
        {
            List<GridData> GridColumns = new List<GridData>();            
            GridColumns.Add(new GridData { FirstColumn = 9, SecondColumn = "suvo8", ThirdColumn = "s9", FourthCoumn = "thrd" });
            GridColumns.Add(new GridData { FirstColumn = 10, SecondColumn = "suvo9", ThirdColumn = "s9", FourthCoumn = "thrd" });
           
            return (IEnumerable<GridData>)GridColumns;

        }

        public ActionResult GRD()
        {
            return PartialView(GetGridData());
        }

GridData is class defined with property  FirstColumn ,SecondColumn,ThirdColumn ,FourthCoumn


I am bale to render the grid inside a window , but with an exception.


If I can pass the exception I will let u know , and you can do the same , at my id "d.suvodeep.cse@gmail.com"
0
Olga
Top achievements
Rank 1
answered on 30 Oct 2011, 09:54 AM
This is how it works for me:

@(Html.Telerik().Window()
    .Name("Window")
    .Modal(true)
    .Title("My big fat title")
    .Scrollable(true)
    .Draggable(true)
    .Resizable()
    .Visible(true)
    .Content(
        @<text>
            @Html.Partial("MyLoginView", new LoginModel())
        </text>
    )
)
Tags
Window
Asked by
Sydney
Top achievements
Rank 1
Answers by
SUVODEEP
Top achievements
Rank 1
Olga
Top achievements
Rank 1
Share this question
or