@@ -1237,26 +1237,29 @@ private void ResetDynamicContext()
12371237 }
12381238 }
12391239
1240- private void QueryDynamicItems ( QueryPageOptions queryOption , IDynamicObjectContext context , bool isAutoQuery = true )
1240+ private void QueryDynamicItems ( QueryPageOptions queryOption , IDynamicObjectContext ? context , bool isAutoQuery = true )
12411241 {
12421242 if ( isAutoQuery )
12431243 {
12441244 _rowsCache = null ;
1245- var items = context . GetItems ( ) ;
1246- if ( context . OnFilterCallback != null )
1245+ if ( context != null )
12471246 {
1248- items = context . OnFilterCallback ( queryOption , items ) ;
1249- }
1250- if ( IsPagination )
1251- {
1252- TotalCount = items . Count ( ) ;
1253- PageCount = ( int ) Math . Ceiling ( TotalCount * 1.0 / Math . Max ( 1 , _pageItems ) ) ;
1254- PageIndex = GetSafePageIndex ( ) ;
1255- items = items . Skip ( ( PageIndex - 1 ) * _pageItems ) . Take ( _pageItems ) ;
1256- }
1257- QueryItems = items . Cast < TItem > ( ) . ToList ( ) ;
1247+ var items = context . GetItems ( ) ;
1248+ if ( context . OnFilterCallback != null )
1249+ {
1250+ items = context . OnFilterCallback ( queryOption , items ) ;
1251+ }
1252+ if ( IsPagination )
1253+ {
1254+ TotalCount = items . Count ( ) ;
1255+ PageCount = ( int ) Math . Ceiling ( TotalCount * 1.0 / Math . Max ( 1 , _pageItems ) ) ;
1256+ PageIndex = GetSafePageIndex ( ) ;
1257+ items = items . Skip ( ( PageIndex - 1 ) * _pageItems ) . Take ( _pageItems ) ;
1258+ }
1259+ QueryItems = items . Cast < TItem > ( ) . ToList ( ) ;
12581260
1259- ResetSelectedRows ( QueryItems ) ;
1261+ ResetSelectedRows ( QueryItems ) ;
1262+ }
12601263 }
12611264 }
12621265
0 commit comments