diff --git a/Mvc.JQuery.DataTables.Common/DataTableConfigVm.cs b/Mvc.JQuery.DataTables.Common/DataTableConfigVm.cs
index c0d59d5..3c04cdb 100644
--- a/Mvc.JQuery.DataTables.Common/DataTableConfigVm.cs
+++ b/Mvc.JQuery.DataTables.Common/DataTableConfigVm.cs
@@ -68,6 +68,8 @@ public string ColumnDefsString
public bool TableTools { get; set; }
+ public bool Buttons { get; set; }
+
public bool AutoWidth { get; set; }
public JToken SearchCols
@@ -96,6 +98,8 @@ public string Dom
str += "C";
if (this.TableTools)
str += "T<\"clear\">";
+ if (this.Buttons)
+ str += "B";
if (this.ShowPageSizes)
str += "l";
if (this.ShowFilterInput)
diff --git a/Mvc.JQuery.DataTables.Tests/packages.config b/Mvc.JQuery.DataTables.Tests/packages.config
index b0f990c..0e107f7 100644
--- a/Mvc.JQuery.DataTables.Tests/packages.config
+++ b/Mvc.JQuery.DataTables.Tests/packages.config
@@ -7,5 +7,6 @@
and render the partial (see example) -
+//include these scripts to use standard features <script type="text/javascript" src="//cdn.datatables.net/1.10.0/js/jquery.dataTables.js"></script> <link rel="stylesheet" href="//cdn.datatables.net/1.10.0/css/jquery.dataTables.css" /> @@ -51,7 +51,7 @@ public class SomeController : Controller <script type="text/javascript" src="/Content/jquery-datatables-column-filter/jquery-ui-timepicker-addon.js"></script> <link rel="stylesheet" href="/Content/jquery-datatables-column-filter/jquery-ui-timepicker-addon.css" /> - //and these if you want to use TableTools (export buttons) + //and these if you want to use TableTools (export buttons, deprecated with Flash). Use Buttons for new version. <script type="text/javascript" src="//cdn.datatables.net/tabletools/2.2.1/js/dataTables.tableTools.min.js"></script> <link rel="stylesheet" href="//cdn.datatables.net/tabletools/2.2.1/css/dataTables.tableTools.css" /> @@ -59,6 +59,16 @@ public class SomeController : Controller <link rel="stylesheet" href="//cdn.datatables.net/colvis/1.1.1/css/dataTables.colVis.css" /> <script type="text/javascript" src="//cdn.datatables.net/colvis/1.1.1/js/dataTables.colVis.min.js"></script> + //And these if you need buttons, note the button colVis is included + <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/buttons/1.7.1/css/buttons.dataTables.min.css" /> + <script type="text/javascript" src="https://cdn.datatables.net/buttons/1.7.1/js/dataTables.buttons.min.js"></script> + <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jszip/2.5.0/jszip.min.js"></script> + <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.36/pdfmake.min.js"></script> + <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.36/vfs_fonts.js"></script> + <script type="text/javascript" src="https://cdn.datatables.net/buttons/1.7.1/js/buttons.colVis.min.js"></script> + <script type="text/javascript" src="https://cdn.datatables.net/buttons/1.7.1/js/buttons.html5.min.js"></script> + <script type="text/javascript" src="https://cdn.datatables.net/buttons/1.7.1/js/buttons.print.min.js"></script> + var dataTablesConfigVm = dataTablesConfigVmHtml.DataTableVm("table-id", (HomeController h) => h.GetUsers(null)) //set options on the config here, see example here diff --git a/Mvc.JQuery.Datatables.Example/Views/Home/_ExampleTable.cshtml b/Mvc.JQuery.Datatables.Example/Views/Home/_ExampleTable.cshtml index 794aeb0..d980338 100644 --- a/Mvc.JQuery.Datatables.Example/Views/Home/_ExampleTable.cshtml +++ b/Mvc.JQuery.Datatables.Example/Views/Home/_ExampleTable.cshtml @@ -10,8 +10,6 @@ - - @@ -22,11 +20,21 @@ + + + + + + + + + + @{ //var vm = Html.DataTableVm("table-id", (HomeController h) => h.GetUsers(null)); var vm = Model; - + } diff --git a/Mvc.JQuery.Datatables.Templates/Views/Shared/DataTable.cshtml b/Mvc.JQuery.Datatables.Templates/Views/Shared/DataTable.cshtml index e27c9b6..e142531 100644 --- a/Mvc.JQuery.Datatables.Templates/Views/Shared/DataTable.cshtml +++ b/Mvc.JQuery.Datatables.Templates/Views/Shared/DataTable.cshtml @@ -62,8 +62,14 @@ { options["oTableTools"] = new JRaw("{ 'sSwfPath': '//cdn.datatables.net/tabletools/2.2.1/swf/copy_csv_xls_pdf.swf' }"); } + if (Model.Buttons) + { + options["buttons"] = new JRaw("[ 'copy', 'csv', 'excel', 'print', 'pdf' ]"); + } + + options["fnServerData"] = new JRaw( - "function(sSource, aoData, fnCallback) { " + + "function(sSource, aoData, fnCallback) { " + " var ajaxOptions = { 'dataType': 'json', 'type': 'POST', 'url': sSource, 'data': aoData, 'success': fnCallback }; " + (Model.AjaxErrorHandler == null ? "" : ("ajaxOptions['error'] = " + Model.AjaxErrorHandler) + "; ") + " $.ajax(ajaxOptions);" + @@ -85,7 +91,7 @@ { options["fnDrawCallback"] = new JRaw(Model.DrawCallback); } - + } var dt = $table.dataTable(@Html.Raw(options.ToString(Formatting.Indented))); diff --git a/Mvc.JQuery.Datatables.sln b/Mvc.JQuery.Datatables.sln index 1dd9889..0df0a88 100644 --- a/Mvc.JQuery.Datatables.sln +++ b/Mvc.JQuery.Datatables.sln @@ -1,7 +1,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.26228.10 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.31402.337 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mvc.JQuery.DataTables.Common", "Mvc.JQuery.DataTables.Common\Mvc.JQuery.DataTables.Common.csproj", "{BFD9EA5A-FE3A-4CE2-9C09-B9E78CE208EE}" EndProject @@ -10,12 +10,15 @@ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mvc.JQuery.DataTables.AspNetCore", "Mvc.JQuery.DataTables.AspNetCore\Mvc.JQuery.DataTables.AspNetCore.csproj", "{59A635A9-751E-4457-BC54-65F85A9AE317}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mvc.JQuery.DataTables.Example", "Mvc.JQuery.DataTables.Example\Mvc.JQuery.DataTables.Example.csproj", "{305FA463-4D61-4E28-8A4B-55A1E74D1BD7}" + ProjectSection(ProjectDependencies) = postProject + {8DA3D5E6-D714-40C3-B6CB-E88D852C5175} = {8DA3D5E6-D714-40C3-B6CB-E88D852C5175} + EndProjectSection EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mvc.JQuery.DataTables.Tests", "Mvc.JQuery.DataTables.Tests\Mvc.JQuery.DataTables.Tests.csproj", "{11A04151-EF52-4828-994F-0837AF9A586C}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mvc.JQuery.DataTables", "Mvc.JQuery.DataTables\Mvc.JQuery.DataTables.csproj", "{2583FCEF-E898-458D-9016-2F294B31F65F}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mvc.JQuery.Datatables.Templates", "Mvc.JQuery.Datatables.Templates\Mvc.JQuery.Datatables.Templates.csproj", "{8DA3D5E6-D714-40C3-B6CB-E88D852C5175}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mvc.JQuery.Datatables.Templates", "Mvc.JQuery.Datatables.Templates\Mvc.JQuery.Datatables.Templates.csproj", "{8DA3D5E6-D714-40C3-B6CB-E88D852C5175}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{CAB6B030-6006-4546-9A32-8F06AC054E1E}" ProjectSection(SolutionItems) = preProject @@ -120,4 +123,7 @@ Global GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {2C227490-FC3E-4FB8-8CC5-01887C32DABE} + EndGlobalSection EndGlobal diff --git a/Mvc.Jquery.DataTables.Tests/Mvc.JQuery.DataTables.Tests.csproj b/Mvc.Jquery.DataTables.Tests/Mvc.JQuery.DataTables.Tests.csproj index 5379960..6d9939a 100644 --- a/Mvc.Jquery.DataTables.Tests/Mvc.JQuery.DataTables.Tests.csproj +++ b/Mvc.Jquery.DataTables.Tests/Mvc.JQuery.DataTables.Tests.csproj @@ -1,5 +1,6 @@ + \ No newline at end of fileDebug @@ -11,6 +12,8 @@Mvc.JQuery.DataTables.Tests v4.5.1 512 ++ true @@ -42,8 +45,24 @@- ..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll - ..\packages\NUnit.3.6.1\lib\net45\nunit.framework.dll ++ +..\packages\NUnitTestAdapter.WithFramework.2.0.0\lib\nunit.core.dll +False ++ +..\packages\NUnitTestAdapter.WithFramework.2.0.0\lib\nunit.core.interfaces.dll +False ++ +..\packages\NUnitTestAdapter.WithFramework.2.0.0\lib\nunit.framework.dll ++ +..\packages\NUnitTestAdapter.WithFramework.2.0.0\lib\nunit.util.dll +False ++ ..\packages\NUnitTestAdapter.WithFramework.2.0.0\lib\NUnit.VisualStudio.TestAdapter.dll +False @@ -106,4 +125,10 @@ + + + +This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. ++