1111using System . Web . WebPages ;
1212#else
1313using Microsoft . AspNetCore . Html ;
14+ using Microsoft . AspNetCore . Http ;
1415using Microsoft . AspNetCore . Mvc . Razor ;
16+ using Microsoft . AspNetCore . Mvc . Rendering ;
1517using Microsoft . AspNetCore . Mvc . ViewFeatures ;
1618using Microsoft . AspNetCore . Routing ;
1719#endif
@@ -63,9 +65,29 @@ string GetIdFromExpression(LambdaExpression expression)
6365
6466 public GriddlyFilter Filter { get ; set ; }
6567
66- public abstract HtmlString RenderUnderlyingValue ( object row ) ;
67- public abstract HtmlString RenderCell ( object row , GriddlySettings settings , bool encode = true ) ;
68- public abstract object RenderCellValue ( object row , bool stripHtml = false ) ;
68+ public abstract HtmlString RenderUnderlyingValue ( object row ,
69+ #if NET45
70+ HtmlHelper html
71+ #else
72+ IHtmlHelper html
73+ #endif
74+ ) ;
75+
76+ public abstract HtmlString RenderCell ( object row , GriddlySettings settings ,
77+ #if NET45
78+ HtmlHelper html ,
79+ #else
80+ IHtmlHelper html ,
81+ #endif
82+ bool encode = true ) ;
83+
84+ public abstract object RenderCellValue ( object row ,
85+ #if NET45
86+ HttpContextBase httpContext ,
87+ #else
88+ HttpContext httpContext ,
89+ #endif
90+ bool stripHtml = false ) ;
6991
7092 public virtual string RenderClassName ( object row , GriddlyResultPage page )
7193 {
@@ -77,11 +99,20 @@ public virtual IDictionary<string, object> GenerateHtmlAttributes(object row, Gr
7799 return null ;
78100 }
79101
80- public virtual HtmlString RenderValue ( object value , bool encode = true )
102+ public virtual HtmlString RenderValue ( object value ,
103+ #if NET45
104+ HtmlHelper html ,
105+ #else
106+ IHtmlHelper html ,
107+ #endif
108+ bool encode = true )
81109 {
82110 if ( value == null )
83111 return null ;
84112
113+ if ( GriddlySettings . ColumnValueFilter != null )
114+ value = GriddlySettings . ColumnValueFilter . Filter ( this , value , html . ViewContext . HttpContext ) ;
115+
85116 if ( Format == null )
86117 {
87118 if ( value is DateTime || value is DateTime ? || value . GetType ( ) . HasCastOperator < DateTime > ( ) )
@@ -169,7 +200,13 @@ public override IDictionary<string, object> GenerateHtmlAttributes(object row, G
169200 return attributes ;
170201 }
171202
172- public override HtmlString RenderCell ( object row , GriddlySettings settings , bool encode = true )
203+ public override HtmlString RenderCell ( object row , GriddlySettings settings ,
204+ #if NET45
205+ HtmlHelper html ,
206+ #else
207+ IHtmlHelper html ,
208+ #endif
209+ bool encode = true )
173210 {
174211 object value = null ;
175212
@@ -199,8 +236,8 @@ public override HtmlString RenderCell(object row, GriddlySettings settings, bool
199236 valueString = ( ( HelperResult ) value ) . ToString ( ) ;
200237 else
201238 {
202- if ( LinkUrl == null ) return RenderValue ( value , encode ) ; //Return directly, to avoid converting to string and back to HtmlString unnecessarily
203- else valueString = RenderValue ( value , encode ) ? . ToHtmlString ( ) ;
239+ if ( LinkUrl == null ) return RenderValue ( value , html , encode ) ; //Return directly, to avoid converting to string and back to HtmlString unnecessarily
240+ else valueString = RenderValue ( value , html , encode ) ? . ToHtmlString ( ) ;
204241 }
205242
206243 if ( row != null && LinkUrl != null && ! string . IsNullOrWhiteSpace ( valueString ) )
@@ -213,7 +250,13 @@ public override HtmlString RenderCell(object row, GriddlySettings settings, bool
213250 return new HtmlString ( valueString ) ;
214251 }
215252
216- public override HtmlString RenderUnderlyingValue ( object row )
253+ public override HtmlString RenderUnderlyingValue ( object row ,
254+ #if NET45
255+ HtmlHelper html
256+ #else
257+ IHtmlHelper html
258+ #endif
259+ )
217260 {
218261 if ( UnderlyingValueTemplate == null ) return null ;
219262
@@ -232,6 +275,9 @@ public override HtmlString RenderUnderlyingValue(object row)
232275 throw new InvalidOperationException ( "Error rendering underlying value or column \" " + Caption + "\" " , ex ) ;
233276 }
234277
278+ if ( GriddlySettings . ColumnValueFilter != null )
279+ value = GriddlySettings . ColumnValueFilter . Filter ( this , value , html . ViewContext . HttpContext ) ;
280+
235281 if ( value == null )
236282 return null ;
237283 else if ( value is HtmlString )
@@ -240,7 +286,13 @@ public override HtmlString RenderUnderlyingValue(object row)
240286 return new HtmlString ( value . ToString ( ) ) ;
241287 }
242288
243- public override object RenderCellValue ( object row , bool stripHtml = false )
289+ public override object RenderCellValue ( object row ,
290+ #if NET45
291+ HttpContextBase httpContext ,
292+ #else
293+ HttpContext httpContext ,
294+ #endif
295+ bool stripHtml = false )
244296 {
245297 object value = null ;
246298
@@ -257,6 +309,8 @@ public override object RenderCellValue(object row, bool stripHtml = false)
257309 throw new InvalidOperationException ( "Error rendering column \" " + Caption + "\" " , ex ) ;
258310 }
259311
312+ if ( GriddlySettings . ColumnValueFilter != null )
313+ value = GriddlySettings . ColumnValueFilter . Filter ( this , value , httpContext ) ;
260314
261315 // TODO: test if we need to match separately -- maybe we get a real string here and could strip?
262316 if ( value is HelperResult )
0 commit comments