In my project, I use the load helper in to layout file, like following
<head> <title>@ViewBag.Title</title> @ContentHelper.LinkCSS(Url.Content("~/Resources/Layout/css/Layout.css"))@* @ContentHelper.LinkCSS(Url.Content("~/Resources/Infragistics/css/structure/infragistics.css")) @ContentHelper.LinkCSS(Url.Content("~/Resources/Infragistics/css/themes/infragistics/infragistics.theme.css"))*@ @ContentHelper.Script(Url.Content("~/Resources/Common/JS/jquery-1.5.1.js")) @ContentHelper.Script(Url.Content("~/Resources/Common/JS/jquery-ui-1.8.11.js")) @ContentHelper.Script(Url.Content("~/Resources/Common/JS/modernizr-1.7.min.js")) @ContentHelper.Script(Url.Content("~/Resources/Infragistics/JS/infragistics.loader.js")) @*@ContentHelper.Script(Url.Content("~/Resources/Infragistics/JS/infragistics.js"))*@ @(Html.Infragistics() .Loader() .Resources("igGrid.*") .ScriptPath(Url.Content("~/Resources/Infragistics/JS/")) .CssPath(Url.Content("~/Resources/Infragistics/css/")) .Render())</head>
and put the grid helper into antoher cshtml file, like following.
@( Html.Infragistics().Grid<MockPosition>().ID("MockPositionGrid") .AvgRowHeight("25") .Columns(column => { column.For(x => x.MarketPrice).DataType("number").HeaderText("Price").Format("0.00").Width("80px"); column.For(x => x.Units).DataType("number").HeaderText("Units").Format("0.00").Width("160px"); column.For(x => x.MarketValue).DataType("number").HeaderText("Value").Format("0.00").Width("160px"); column.For(x => x.Cost).DataType("number").HeaderText("Cost").Format("0.00").Width("160px"); column.For(x => x.BookValue).DataType("number").HeaderText("Book Value").Format("0.00").Width("160px"); column.For(x => x.FxUnrealizedGainLoss).DataType("number").HeaderText("FX P/L").Format("0.00").Width("160px"); column.For(x => x.UnrealizedGainLoss).DataType("number").HeaderText("Mkt P/L").Format("0.00").Width("160px"); column.For(x => x.Duration).DataType("number").HeaderText("Duration").Format("0.00").Width("100px"); }) .Features(features => { features.Paging(); features.Sorting(); }) .DataSourceUrl(Url.Action("RequestMockPosition", "Home")) .Width("100%") .Height("100%") .DataBind() .Render()
It does not works.
But if I put the loader and grid into a same file, it works.
Is there any way to allow I put loader into layout file, and put grid into another file?
Hello spark_li,
It should work. Could you try to put the loader at the end of layout file? it should be after the grid initialization, because sometimes cause problems in head.
I noticed that you added script resource .Resources("igGrid.*") in loader. It is necessary, because MVC wrapper load it automatically.
Regards,
Stanimir
Stanimir,
I was having the same problem when I read about the Known Issues and Limitations 2012 vol1 in the online help, and found: "MVC Loader does not function properly in an MVC Razor layout view solution".
So, I'm guessing that I have to place the call to Html.Infragistics().Loader() into every view? Could you confirm this?
Thanks