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
Hi I have the same situation and I'm trying to use Loader to change localization to Spanish ... No way, the grid is allways in English ... Any idea about what is happening ?
@section Grid {
@(Html.Infragistics() .Loader() .ScriptPath(Url.Content("~/Scripts/Infragistics/")) .CssPath(Url.Content("~/Content/Infragistics/")) .Locale("es") .Resources("igGrid.*") .Render() )
@(Html.Infragistics() .Grid(Model) .ID("gridPrincipal") .Width("100%") .Height("100%") .PrimaryKey("IDProjeto") .AutoGenerateColumns(false) .AutoGenerateLayouts(false) .Columns(column => { column.Unbound("Editar").HeaderText("Editar").Width("8%").Template("<center><a href='/Ease_Manager/GP/Projetos?idProjeto=${IDProjeto}' alt='Editar' title='Editar esse projeto.'><i class='glyphicon glyphicon-edit'></i></a></center>"); column.Unbound("Excluir").HeaderText("Excluir").Width("8%").Template("<center><a href='#' onclick='submitExcluir(${IDProjeto})' alt='Excluir' title='Excluir esse projeto.'><i class='glyphicon glyphicon-trash'></i></a></center>"); column.For(x => x.NomeProjeto).HeaderText("Nome").Width("44%"); column.For(x => x.DescricaoProjeto).HeaderText("Descrição").Width("40%"); }) .Features(features => { features.Sorting().Type(OpType.Local).ColumnSettings(setting => { setting.ColumnSetting().ColumnKey("Editar").AllowSorting(false); setting.ColumnSetting().ColumnKey("Excluir").AllowSorting(false);}); features.Paging().Type(OpType.Local); features.Filtering().Type(OpType.Local).ColumnSettings(setting => { setting.ColumnSetting().ColumnKey("Editar").AllowFiltering(false); setting.ColumnSetting().ColumnKey("Excluir").AllowFiltering(false);}); features.ColumnMoving().Mode(MovingMode.Immediate).MoveType(MovingType.Dom).ColumnSettings(setting => { setting.ColumnSetting().ColumnKey("Editar").AllowMoving(false); setting.ColumnSetting().ColumnKey("Excluir").AllowMoving(false);}); ; features.Resizing().ColumnSettings(setting => { setting.ColumnSetting().ColumnKey("Editar").AllowResizing(false); setting.ColumnSetting().ColumnKey("Excluir").AllowResizing(false);}); features.Hiding().ColumnSettings(setting => { setting.ColumnSetting().ColumnKey("Editar").AllowHiding(false); setting.ColumnSetting().ColumnKey("Excluir").AllowHiding(false);}); ; }) .DataSource(ViewBag.ListaProjetos) .DataBind() .Render() )
Glad you like it, Kev :)
Such situations can be tricky to figure out!Cheers!
Thank you SO much for this post! I have been struggling with this all morning, came across this, tried it, and it is finally working.
I greatly appreciate you putting this out there.
Kevin
I see - they must have been left over from my experiments on the sample (sorry about that).Still, glad you liked the solution :)
Borislav- Thanks for the help. If in the example above I remove "@RenderSection("Header", true) " from the _Layout page, and the <div></div> from the view, it works well.