PDA

View Full Version : [CLOSED] [MVC] Getting AbstactComponent from partial view



alex303
Oct 29, 2013, 8:41 PM
Hello, please take a look at my sample

view1.cshtml

@using Ext.Net
@using Ext.Net.MVC
@model Models.ViewModel.Frames.IViewFrame
@{
var ext = Html.X();

Html.RenderPartial("Grid", Model);

if (Model.Details != null && Model.Details.Count > 0)
{
@(ext.BoxSplitter())
@(ext.TabPanel()
.Layout(LayoutType.Fit)
.Flex(1)
.ItemsFromPartial("GridTabs", Model.Details))
}
}
}

GridTabs.cshtml

@model ICollection<Models.ViewModel.Frames.IViewFrame>
@{
foreach (var viewFrame in Model)
{
Html.RenderPartial("GridContainer", viewFrame);
}
}

I want to avoid the GridTabs.cshtml and move its logic in to view1.cshtml

Something like:


@using System.Collections.ObjectModel
@using Ext.Net
@using Ext.Net.MVC
@model Models.ViewModel.Frames.IViewFrame
@{
var ext = Html.X();

Html.RenderPartial("Grid", Model);

if (Model.Details != null && Model.Details.Count > 0)
{
var items = new Collection<AbstractComponent>();
foreach (var viewFrame in Model.Details)
{
items.Add(MAKE_ABSTACT_COMPONENT_FROM_PARTIAL_VIEW ("GridContainer", viewFrame )); //// Need this method
}
@(ext.BoxSplitter())
@(ext.TabPanel()
.Layout(LayoutType.Fit)
.Flex(1)
.Items(items))
//.ItemsFromPartial("GridTabs", Model.Details))
}
}
}

Is there any such method (MAKE_ABSTACT_COMPONENT_FROM_PARTIAL_VIEW) in Ext.net?

Baidaly
Oct 29, 2013, 11:15 PM
Hello!

Welcome to our forum!

I'm afraid, we don't have such method. You should use loop and add each item to the control.

However, I'll ask my colleagues.

Daniil
Oct 30, 2013, 7:00 AM
Hi,

In other words, you need to call ItemsFromPartial several times on some container?

This is working:

@Html.X().Container().ItemsFromPartial("Partial").ItemsFromPartial("Partial")

I think it can be done in a loop.

View

@{
var X = Html.X();
}

<!DOCTYPE html>
<html>
<head>
<title>Ext.Net.MVC v2 Example</title>
</head>
<body>
@X.ResourceManager()

@{
var ct = new Container().ToBuilder();

for (int i = 0; i < 5; i++) {
ct.ItemsFromPartial("Partial", i);
}
}

@ct
</body>
</html>


Partial View

@model int

@{
var X = Html.X();
}

@X.Label().Html("Hello " + Model + "!<br/>")

P.S. It is nice to see someone from Russia as a premium member:)

alex303
Oct 30, 2013, 9:17 AM
Thank you Daniil, I'll try...

ps. Yeah, I'm glad to see russian developers and supports in this project...

---

upd:
I just checked this approach. It works well.
We can close this thread.
Thx again.

Daniil
Dec 23, 2014, 7:22 AM
Hi @alex303,

Just for your information - Ext.NET hires! (http://forums.ext.net/showthread.php?48911-Ext-NET-hires)