File tree 6 files changed +54
-7
lines changed
6 files changed +54
-7
lines changed Original file line number Diff line number Diff line change
1
+ using System ;
2
+ using System . Collections . Generic ;
3
+ using System . Linq ;
4
+ using System . Text ;
5
+ using System . Threading . Tasks ;
6
+
7
+ namespace Griddly . Mvc
8
+ {
9
+ //TODO: Put GriddlySettings into GriddlyContext so that it doesn't need to be passed in separately
10
+ public class EmptyGridMessageTemplateParams
11
+ {
12
+ public GriddlyResultPage ResultPage { get ; set ; }
13
+ public GriddlySettings Settings { get ; set ; }
14
+ }
15
+ }
Original file line number Diff line number Diff line change 87
87
<Link >Properties\CommonAssemblyInfo.cs</Link >
88
88
</Compile >
89
89
<Compile Include =" DynamicLinq.cs" />
90
+ <Compile Include =" EmptyGridMessageTemplateParams.cs" />
90
91
<Compile Include =" Exceptions\DapperGriddlyException.cs" />
91
92
<Compile Include =" GriddlyContext.cs" />
92
93
<Compile Include =" GriddlyCookieFilterValueProvider.cs" />
Original file line number Diff line number Diff line change @@ -83,6 +83,8 @@ public GriddlySettings()
83
83
TableClassName = Css . TableDefault ;
84
84
FooterTemplate = DefaultFooterTemplate ;
85
85
HeaderTemplate = DefaultHeaderTemplate ;
86
+ EmptyGridMessageTemplate = DefaultEmptyGridMessageTemplate ;
87
+ EmptyGridMessage = DefaultEmptyGridMessage ;
86
88
PageSize = DefaultPageSize ;
87
89
InitialFilterMode = DefaultInitialFilterMode ;
88
90
//AllowedFilterModes = DefaultAllowedFilterModes;
@@ -149,6 +151,11 @@ public static void ConfigureBootstrap4Defaults()
149
151
public Func < GriddlyResultPage , object > FooterTemplate { get ; set ; }
150
152
public Func < GriddlyResultPage , object > HeaderTemplate { get ; set ; }
151
153
154
+ public static Func < EmptyGridMessageTemplateParams , object > DefaultEmptyGridMessageTemplate { get ; set ; }
155
+ public Func < EmptyGridMessageTemplateParams , object > EmptyGridMessageTemplate { get ; set ; }
156
+ public static string DefaultEmptyGridMessage { get ; set ; }
157
+ public string EmptyGridMessage { get ; set ; }
158
+
152
159
public Dictionary < string , Func < object , object > > RowIds { get ; protected set ; }
153
160
154
161
public virtual bool HasRowClickUrl
Original file line number Diff line number Diff line change 1696
1696
// https://github.com/programcsharp/griddly/issues/79
1697
1697
this . $element . find ( "tbody.data" ) . html ( html . children ( "tbody" ) . html ( ) ) ;
1698
1698
1699
- var tfoot = this . $element . find ( "tfoot" ) ;
1699
+ var tfoot = this . $element . find ( "tfoot.totals-tfoot" ) ;
1700
+ if ( tfoot . length && html . children ( "tfoot.totals-tfoot" ) . length )
1701
+ tfoot . replaceWith ( html . children ( "tfoot.totals-tfoot" ) ) ;
1700
1702
1701
- if ( tfoot . length && html . children ( "tfoot" ) . length )
1702
- tfoot . replaceWith ( html . children ( "tfoot" ) ) ;
1703
+ var emptyMessage = this . $element . find ( "tfoot.empty-grid-message" ) ;
1704
+ if ( emptyMessage . length && html . children ( "tfoot.empty-grid-message" ) . length )
1705
+ emptyMessage . replaceWith ( html . children ( "tfoot.empty-grid-message" ) ) ;
1703
1706
1704
1707
var startRecord = this . options . pageNumber * this . options . pageSize ;
1705
1708
Original file line number Diff line number Diff line change 39
39
{
40
40
new GriddlyButton () { Text = " Dropdown Test" }
41
41
.Add (new GriddlyButton () { Text = " UrlHelper Test" , Argument = Url .Action (" About" ) })
42
- }
42
+ },
43
+ EmptyGridMessageTemplate = @< text >< div class = " alert alert-warning" > @item .Settings .EmptyGridMessage < / div >< / text > ,
44
+ EmptyGridMessage = " Sorry, no records were found"
43
45
}
44
46
.Column(x => x.Id, filter: x => x.FilterBox(FilterDataType.Integer))
45
47
.Column(x => x.Item, filter: x => x.FilterList(groupedList))
Original file line number Diff line number Diff line change 286
286
</tbody >
287
287
@if (settings .Columns .Any (x => x .SummaryFunction != null || x .SummaryValue != null ))
288
288
{
289
- <tfoot >
289
+ <tfoot class = " totals-tfoot " >
290
290
<tr >
291
291
@foreach ( GriddlyColumn column in settings .Columns )
292
292
{
295
295
</tr >
296
296
</tfoot >
297
297
}
298
+
299
+ @if (settings .EmptyGridMessage != null ) {
300
+ < tfoot class = " empty-grid-message" style = " @(Model.Total > 0 ? " display : none ;" : null)" >
301
+ < tr >
302
+ < td colspan = " @settings.Columns.Count" >
303
+ @if (settings .EmptyGridMessageTemplate != null )
304
+ {
305
+ @settings .EmptyGridMessageTemplate (new EmptyGridMessageTemplateParams () { ResultPage = Model , Settings = settings })
306
+ }
307
+ else
308
+ {
309
+ @Model .Settings .EmptyGridMessage
310
+ }
311
+ < / td >
312
+ < / tr >
313
+ < / tfoot >
314
+ }
315
+
298
316
@if (isFirstRender )
299
317
{
300
- @: </table >
301
- @: </div >
318
+ @: </table >
319
+ @: </div >
320
+
302
321
<div class =" griddly-footer" >
303
322
@if (settings .FooterTemplate == null || simple )
304
323
{
You can’t perform that action at this time.
0 commit comments