Bundle Js scripts in ASP.NET Core 6 MVC to display htmlgrid from mvcjqgrid

137 views Asked by At

I am using the mvcjqgrid nuget package to create a grid in an ASP.NET Core 6 MVC project but the @Scripts.Render() method doesn't work and there is no bundleconfig.json to bundle the js.

There is a no cdn url for the package to use in script tag.

So basically I want to know how to use js libraries inside views.

I am using this code in a partial view

<div class="col-md-12">
    @(Html.Grid(COMMUNITIES_GRID)
          .AddColumn(new Column("ID"))
          .AddColumn(new Column("ID").SetHidden(true))
          .SetUrl(Url.Action("GetCommunitiesGrid"))
          .SetEmptyRecords("No Communities Found.");            
     )
</div>

This renders in DOM when i execute the code instead of the grid

Thanks in advance.

I tried to use GridMVC but it needs the System.Web.Mvc which isn't available.

In an old project written for .NET Framework 4.7, this code is written which I guess renders the js.

@section header {
    @Scripts.Render("~/bundles/jquery-2.0.3")
    @Scripts.Render("~/bundles/jqueryui-1.10.3")
    @Scripts.Render("~/bundles/jqGrid")
    @Scripts.Render("~/bundles/sortable")
    @Scripts.Render("~/bundles/bootstrap")
    @Scripts.Render("~/bundles/communities")
    @Styles.Render("~/Content/themes/base/css")
    @Styles.Render("~/Content/jqGrid")
    @Styles.Render("~/Content/fineuploader")
    @Scripts.Render("~/bundles/jqueryval")
}
@(Html.Grid(COMMUNITIES_GRID)
      .AddColumn(new Column("ID").SetHidden(true))
      .AddColumn(new Column("cell.Brand").SetSortable(true).SetAlign(MvcJqGrid.Enums.Align.Center).SetLabel("Brand").SetWidth(125))
      .AddColumn(new Column("cell.Market").SetSortable(true).SetAlign(MvcJqGrid.Enums.Align.Center).SetLabel("Market").SetWidth(125))
      .AddColumn(new Column("cell.ISPName").SetSortable(true).SetAlign(MvcJqGrid.Enums.Align.Center).SetLabel("ISP Community Label").SetWidth(125))                                                                                                                              
      .AddColumn(new Column("cell.Name").SetSortable(true).SetAlign(MvcJqGrid.Enums.Align.Center).SetLabel("Community").SetWidth(125))

     .SetUrl(Url.Action("GetCommunities"))
     .SetAutoWidth(true)
     .SetRowNum(10)
     .SetRowList(new[] { 10, 15, 20, 50 })
     .SetPager("pager")
     .SetRequestType(MvcJqGrid.Enums.RequestType.Post)
     .OnSelectRow("onRowSelected(rowid, status)")
     .OnLoadComplete("CommunitiesLoadCompleted()")
     .SetViewRecords(true)
     .OnSelectRow("onRowSelected(rowid, status)")
     .OnSelectAll("onAllRowSelected(aRowids,status)")
     .SetLoadOnce(false)
     .SetEmptyRecords("No Communities Found")

But it also has a bundleconfig.json in the project.

0

There are 0 answers