Skip to content

Commit

Permalink
released v3.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ekondur committed May 3, 2023
1 parent 3c60787 commit 27e71a0
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 26 deletions.
8 changes: 4 additions & 4 deletions DatatableJS.Net/DatatableJS.Net.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
<RepositoryType>git</RepositoryType>
<PackageLicenseFile>LICENSE.md</PackageLicenseFile>
<PackageTags>C#, Helper, Jquery Datatables, Entity Framework, Mvc</PackageTags>
<PackageReleaseNotes>Persist search value of individual column with statesave</PackageReleaseNotes>
<AssemblyVersion>3.6.1.0</AssemblyVersion>
<FileVersion>3.6.1.0</FileVersion>
<Version>3.6.1</Version>
<PackageReleaseNotes>Added separated RenderHtml and RenderScript methods as an alternative to Render method.</PackageReleaseNotes>
<AssemblyVersion>3.7.0.0</AssemblyVersion>
<FileVersion>3.7.0.0</FileVersion>
<Version>3.7.0</Version>
<PackageIcon>datatable-js.png</PackageIcon>
<PackageIconUrl />
<GenerateDocumentationFile>true</GenerateDocumentationFile>
Expand Down
23 changes: 15 additions & 8 deletions DatatableJS.Net/JSHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ private static string GetEnumDescription(this Enum enumValue)
}

/// <summary>
/// Render datatable script for prepared grid builder
/// Render both html and script
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="grid"></param>
Expand All @@ -73,18 +73,28 @@ public static MvcHtmlString Render<T>(this GridBuilder<T> grid)
{
var html = RenderHtmlString(grid);
var script = RenderScriptString(grid);
return new MvcHtmlString(html+script);
return new MvcHtmlString(html + Environment.NewLine + script);
}


/// <summary>
/// Render only html
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="grid"></param>
/// <returns></returns>
public static MvcHtmlString RenderHtml<T>(this GridBuilder<T> grid)
{

return new MvcHtmlString(RenderHtmlString(grid));
}

/// <summary>
/// Render only script
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="grid"></param>
/// <returns></returns>
public static MvcHtmlString RenderScript<T>(this GridBuilder<T> grid)
{

return new MvcHtmlString(RenderScriptString(grid));
}

Expand All @@ -100,8 +110,6 @@ private static string RenderHtmlString<T>(this GridBuilder<T> grid)

var tfootInit = string.Empty;



var html = $@"
<table id=""{grid._name}"" class=""{grid._cssClass}"" style=""width:100%"">
<thead>
Expand All @@ -116,7 +124,6 @@ private static string RenderHtmlString<T>(this GridBuilder<T> grid)
return html;
}


private static string RenderScriptString<T>(this GridBuilder<T> grid)
{
var tfootInit = string.Empty;
Expand Down
4 changes: 2 additions & 2 deletions DatatableJS/DatatableJS.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
<RepositoryUrl>https://github.com/ekondur/DatatableJS</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageTags>C#, Tag Helper, Jquery Datatables, Entity Framework, Mvc, Net Core</PackageTags>
<PackageReleaseNotes>Persist search value of individual column with statesave</PackageReleaseNotes>
<PackageReleaseNotes>Added separated RenderHtml and RenderScript methods as an alternative to Render method. Added Dom feature.</PackageReleaseNotes>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Version>3.6.1</Version>
<Version>3.7.0</Version>
<PackageIcon>datatable-js.png</PackageIcon>
<PackageIconUrl />
<GenerateDocumentationFile>true</GenerateDocumentationFile>
Expand Down
27 changes: 15 additions & 12 deletions DatatableJS/JSHelper.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
using Microsoft.AspNetCore.Html;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.AspNetCore.Mvc.ViewFeatures;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;

namespace DatatableJS
{
Expand Down Expand Up @@ -52,16 +49,22 @@ public static JSHelper JS(this IHtmlHelper helper)
}

/// <summary>
/// Render datatable script for prepared grid builder
/// Render both html and script
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="grid"></param>
/// <returns></returns>
public static IHtmlContent Render<T>(this GridBuilder<T> grid)
{
return new HtmlString(RenderHtml<T>(grid).ToString() + RenderScript<T>(grid).ToString());
return new HtmlString(RenderHtml(grid).ToString() + Environment.NewLine + RenderScript(grid).ToString());
}

/// <summary>
/// Render only html
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="grid"></param>
/// <returns></returns>
public static IHtmlContent RenderHtml<T>(this GridBuilder<T> grid)
{
var tfoot = grid._columnSearching ?
Expand All @@ -71,7 +74,6 @@ public static IHtmlContent RenderHtml<T>(this GridBuilder<T> grid)
</tr>
</tfoot>"
: string.Empty;


var html = $@"
<table id=""{grid._name}"" class=""{grid._cssClass}"" style=""width:100%"">
Expand All @@ -82,13 +84,16 @@ public static IHtmlContent RenderHtml<T>(this GridBuilder<T> grid)
</thead>
{tfoot}
</table>";



return new HtmlString(html);
}



/// <summary>
/// Render only script
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="grid"></param>
/// <returns></returns>
public static IHtmlContent RenderScript<T>(this GridBuilder<T> grid)
{
var tfootInit = string.Empty;
Expand Down Expand Up @@ -182,7 +187,6 @@ public static IHtmlContent RenderScript<T>(this GridBuilder<T> grid)
$"lengthMenu: {string.Format("[[{0}], [{1}]]", string.Join(", ", grid._lengthMenuValues), string.Join(", ", grid._lengthMenuDisplayedTexts.Select(a => string.Concat(@"""", a, @""""))))},"
;


var script = $@"<script>
$(document).ready(function () {{
$('#{grid._name}').DataTable( {{
Expand Down Expand Up @@ -267,7 +271,6 @@ public static IHtmlContent RenderScript<T>(this GridBuilder<T> grid)
return new HtmlString(script);
}


private static string GetDataStr<T>(this GridBuilder<T> grid)
{
var filters = string.Format("d.filters = {0}{1}", JsonConvert.SerializeObject(grid._filters), string.IsNullOrEmpty(grid._data) ? string.Empty : ",");
Expand Down

0 comments on commit 27e71a0

Please sign in to comment.