Skip to content

Commit 95b5909

Browse files
committed
Corrected namespace for embedded razor view
Updated version of ASP.NET Core MVC used Updated instructions in the example project for using this in ASP.NET Core
1 parent 9ae2b5c commit 95b5909

File tree

6 files changed

+39
-18
lines changed

6 files changed

+39
-18
lines changed

Mvc.JQuery.DataTables.AspNetCore.Example/Mvc.JQuery.DataTables.AspNetCore.Example.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
</PropertyGroup>
1111
<ItemGroup>
1212
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.0.0" />
13-
<PackageReference Include="Microsoft.AspNetCore" Version="1.0.3" />
14-
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.0.1" />
13+
<PackageReference Include="Microsoft.AspNetCore" Version="1.1.0" />
14+
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.0" />
1515
<PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="1.0.1" />
1616
</ItemGroup>
1717
<ItemGroup>

Mvc.JQuery.DataTables.AspNetCore.Example/Startup.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ public Startup(IHostingEnvironment env)
2424
public void ConfigureServices(IServiceCollection services)
2525
{
2626
// Add framework services.
27-
services.AddMvcJQueryDataTables();
2827
services.AddMvc();
28+
services.AddMvcJQueryDataTables();
2929
}
3030

3131
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.

Mvc.JQuery.DataTables.AspNetCore.Example/Views/Home/Index.cshtml

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,50 @@
11
@model Mvc.JQuery.DataTables.DataTableConfigVm
22
@{
3-
ViewData["Title"] = "Mvc.JQuery.DataTables";
3+
ViewData["Title"] = "Mvc.JQuery.DataTables.AspNetCore";
44
}
55

66
<script type="text/javascript" src="http://balupton.github.com/jquery-syntaxhighlighter/scripts/jquery.syntaxhighlighter.min.js"></script>
77
<script type="text/javascript"> $.SyntaxHighlighter.init();</script>
88

99
<h1>Grid example <small> See also <a href="/facet">Faceted search example</a></small></h1>
1010
<pre>
11-
Nuget install-package Mvc.JQuery.DataTables
11+
Nuget install-package Mvc.JQuery.DataTables.AspNetCore
1212

13-
Nuget install-package <a href="https://github.com/mcintyre321/EmbeddedResourceVirtualPathProvider">EmbeddedResourceVirtualPathProvider</a> <i>or</i> Nuget install-package Mvc.JQuery.DataTables.Templates
13+
<i>Optionally</i> Nuget install-package Mvc.JQuery.DataTables.Templates
1414
</pre>
1515
<p>
16-
Create a controller (see <a style="color: dodgerblue;" href="https://github.com/mcintyre321/mvc.jquery.datatables/tree/master/Mvc.JQuery.DataTables.Example/Controllers/HomeController.cs">example</a>)
16+
If not using Mvc.JQuery.DataTables.Templates, configure DataTables to use its embedded resources in your Startup class
17+
</p>
18+
<pre class="highlight">
19+
public class Startup
20+
{
21+
public void ConfigureServices(IServiceCollection services)
22+
{
23+
services.AddMvc();
24+
services.AddMvcJQueryDataTables();
25+
}
26+
27+
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
28+
{
29+
...
30+
app.UseMvcJQueryDataTables();
31+
app.UseMvc(...);
32+
}
33+
}
34+
</pre>
35+
36+
<p>
37+
Create a controller (see <a style="color: dodgerblue;" href="https://github.com/mcintyre321/mvc.jquery.datatables/tree/master/Mvc.JQuery.DataTables.AspNetCore.Example/Controllers/HomeController.cs">example</a>)
1738
</p>
1839
<pre class="highlight">
1940
public class SomeController : Controller
2041
{
21-
public ActionResult Index()
42+
public IActionResult Index()
2243
{
2344
var getDataUrl = Url.Action(nameof(HomeController.GetUsers));
2445
var vm = DataTablesHelper.DataTableVm&ltUserTableRowViewModel>("idForTableElement", getDataUrl);
2546

26-
... configure data table options (see <a href="https://github.com/mcintyre321/mvc.jquery.datatables/tree/master/Mvc.JQuery.DataTables.Example/Controllers/HomeController.cs">HomeController.cs</a>)
47+
... configure data table options (see <a href="https://github.com/mcintyre321/mvc.jquery.datatables/tree/master/Mvc.JQuery.DataTables.AspNetCore.Example/Controllers/HomeController.cs">HomeController.cs</a>)
2748

2849

2950
return View(vm);
@@ -39,7 +60,7 @@ public class SomeController : Controller
3960
</pre>
4061

4162
<p>
42-
and render the partial (see <a href="https://github.com/mcintyre321/mvc.jquery.datatables/tree/master/Mvc.JQuery.DataTables.Example/Views/Home/Index.cshtml">example</a>)
63+
and render the partial (see <a href="https://github.com/mcintyre321/mvc.jquery.datatables/tree/master/Mvc.JQuery.DataTables.AspNetCore.Example/Views/Home/Index.cshtml">example</a>)
4364

4465
<pre class="highlight">
4566
//include these scripts to use standard features
@@ -62,7 +83,7 @@ public class SomeController : Controller
6283
&lt;script type="text/javascript" src="//cdn.datatables.net/colvis/1.1.1/js/dataTables.colVis.min.js">&lt;/script>
6384

6485
var dataTablesConfigVm = dataTablesConfigVmHtml.DataTableVm("table-id", (HomeController h) => h.GetUsers(null))
65-
//set options on the config here, see <a href="https://github.com/mcintyre321/mvc.jquery.datatables/tree/master/Mvc.JQuery.Datatables.Example/Views/Home/_ExampleTable.cshtml">example here</a>
86+
//set options on the config here, see <a href="https://github.com/mcintyre321/mvc.jquery.datatables/tree/master/Mvc.JQuery.Datatables.AspNetCore.Example.AspNetCore/Views/Home/_ExampleTable.cshtml">example here</a>
6687

6788
@@Html.Partial("DataTable", Model)
6889
</pre>

Mvc.JQuery.DataTables.AspNetCore/Extensions.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@ public static class ConfigureServicesExtensions
99
{
1010
public static IServiceCollection AddMvcJQueryDataTables(this IServiceCollection services)
1111
{
12-
var dataTablesRazorViewAssembly = typeof(Mvc.JQuery.DataTables.DataTableConfigVm).GetTypeInfo().Assembly;
12+
var dataTablesViewModelType = typeof(Mvc.JQuery.DataTables.DataTableConfigVm).GetTypeInfo();
1313
var settings = new Mvc.JQuery.DataTables.Settings
1414
{
15-
FileProvider = new EmbeddedFileProvider(dataTablesRazorViewAssembly),
15+
FileProvider = new EmbeddedFileProvider(dataTablesViewModelType.Assembly,
16+
dataTablesViewModelType.Namespace),
1617
};
1718
services.AddSingleton(settings);
1819
services.Configure<RazorViewEngineOptions>(s => s.FileProviders.Add(settings.FileProvider));

Mvc.JQuery.DataTables.AspNetCore/Mvc.JQuery.DataTables.AspNetCore.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
</PropertyGroup>
99

1010
<ItemGroup>
11-
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.0.2" />
12-
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.0.1" />
13-
<PackageReference Include="Microsoft.Extensions.FileProviders.Embedded" Version="1.0.1" />
11+
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.0" />
12+
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.1.0" />
13+
<PackageReference Include="Microsoft.Extensions.FileProviders.Embedded" Version="1.1.0" />
1414
</ItemGroup>
1515

1616
<ItemGroup>

Mvc.JQuery.Datatables.Templates/Views/Shared/DataTable.cshtml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
@using System.Data.Odbc
2-
@using System.Linq
1+
@using System.Linq
32
@using Mvc.JQuery.DataTables
43
@using Newtonsoft.Json
54
@using Newtonsoft.Json.Linq

0 commit comments

Comments
 (0)