File tree Expand file tree Collapse file tree 7 files changed +57
-1
lines changed Expand file tree Collapse file tree 7 files changed +57
-1
lines changed Original file line number Diff line number Diff line change 4
4
using System . Web . Mvc ;
5
5
using Examples . Data ;
6
6
using Examples . Mvc . ViewModels ;
7
+ using JQDT . Models ;
7
8
using JQDT . MVC ;
8
9
9
10
public class CustomersController : Controller
@@ -21,7 +22,7 @@ public ActionResult Index()
21
22
return View ( ) ;
22
23
}
23
24
24
- [ JQDataTable ]
25
+ [ CustomJQDataTable ]
25
26
public ActionResult GetCustomersData ( )
26
27
{
27
28
var data = this . context . Customers . Select ( x => new CustomerViewModel
@@ -42,4 +43,14 @@ public ActionResult GetCustomersData()
42
43
return this . View ( data ) ;
43
44
}
44
45
}
46
+
47
+ public class CustomJQDataTableAttribute : JQDataTableAttribute
48
+ {
49
+ public override void OnDataProcessed ( object data , RequestInfoModel requestInfoModel )
50
+ {
51
+ var processedData = ( ( IQueryable < CustomerViewModel > ) data ) . Where ( x => x . CustomerID > 10 && x . CustomerID < 20 ) ;
52
+ var list = processedData . ToList ( ) ;
53
+ data = list ;
54
+ }
55
+ }
45
56
}
Original file line number Diff line number Diff line change 282
282
<Project >{d845ab6d-1887-4597-9256-148ad0a11459}</Project >
283
283
<Name >JQDT.MVC</Name >
284
284
</ProjectReference >
285
+ <ProjectReference Include =" ..\..\JQDT\JQDT.csproj" >
286
+ <Project >{C82E4675-88AB-4B78-8475-F1521BDAE330}</Project >
287
+ <Name >JQDT</Name >
288
+ </ProjectReference >
285
289
<ProjectReference Include =" ..\Examples.Data\Examples.Data.csproj" >
286
290
<Project >{082A75A9-D2AE-4BA6-84EF-606852B1B88A}</Project >
287
291
<Name >Examples.Data</Name >
Original file line number Diff line number Diff line change @@ -35,12 +35,22 @@ public override void OnActionExecuted(ActionExecutedContext filterContext)
35
35
}
36
36
}
37
37
38
+ /// <summary>
39
+ /// Called when [data processed].
40
+ /// </summary>
41
+ /// <param name="data">The data.</param>
42
+ /// <param name="requestInfoModel">The request information model.</param>
43
+ public virtual void OnDataProcessed ( object data , RequestInfoModel requestInfoModel )
44
+ {
45
+ }
46
+
38
47
private void PerformOnActionExecuted ( ActionExecutedContext filterContext )
39
48
{
40
49
var dataCollectionType = filterContext . Controller . ViewData . Model . GetType ( ) ;
41
50
var dependencyResolver = new DI . DependencyResolver ( ) ;
42
51
var applicationInitizlizationFunction = ExecuteFunctionProvider < ActionExecutedContext > . GetAppInicializationFunc ( dataCollectionType , typeof ( ApplicationMvc < > ) ) ;
43
52
var mvcApplication = applicationInitizlizationFunction ( filterContext , dependencyResolver ) ;
53
+ this . SubscribeToEvents ( mvcApplication ) ;
44
54
var result = ( ResultModel ) mvcApplication . Execute ( ) ;
45
55
46
56
filterContext . Result = this . FormatResult ( new
@@ -55,6 +65,11 @@ private void PerformOnActionExecuted(ActionExecutedContext filterContext)
55
65
base . OnActionExecuted ( filterContext ) ;
56
66
}
57
67
68
+ private void SubscribeToEvents ( IApplicationBase application )
69
+ {
70
+ application . OnDataProcessed += this . OnDataProcessed ;
71
+ }
72
+
58
73
private ActionResult FormatResult ( object resultModel )
59
74
{
60
75
var jsonResult = new JsonResult
Original file line number Diff line number Diff line change 5
5
using System . Linq ;
6
6
using System . Text ;
7
7
using JQDT . DataProcessing ;
8
+ using JQDT . Delegates ;
8
9
using JQDT . DI ;
9
10
using JQDT . ModelBinders ;
10
11
using JQDT . Models ;
@@ -27,6 +28,11 @@ public ApplicationBase(IDependencyResolver dependencyResolver)
27
28
this . dependencyResolver = dependencyResolver ;
28
29
}
29
30
31
+ /// <summary>
32
+ /// Occurs when [on data processed].
33
+ /// </summary>
34
+ public event DataProcessorEventHandler OnDataProcessed ;
35
+
30
36
/// <summary>
31
37
/// Application entry point method. Executes all data processors.
32
38
/// </summary>
@@ -46,6 +52,8 @@ public ResultModel Execute()
46
52
var dataProcessChain = this . GetDataProcessChain ( requestModel . Helpers . DataCollectionType ) ;
47
53
var processedData = dataProcessChain . ProcessData ( data , requestModel ) ;
48
54
55
+ this . OnDataProcessed ( processedData , requestModel ) ;
56
+
49
57
result . Data = processedData . ToList ( ) . Select ( x => ( object ) x ) . ToList ( ) ;
50
58
result . Draw = requestModel . TableParameters . Draw ;
51
59
result . RecordsTotal = data . Count ( ) ;
Original file line number Diff line number Diff line change 1
1
namespace JQDT . Application
2
2
{
3
+ using JQDT . Delegates ;
3
4
using JQDT . Models ;
4
5
5
6
/// <summary>
6
7
/// Base interface for <see cref="ApplicationBase{T}"/>
7
8
/// </summary>
8
9
public interface IApplicationBase
9
10
{
11
+ /// <summary>
12
+ /// Occurs when [on data processed].
13
+ /// </summary>
14
+ event DataProcessorEventHandler OnDataProcessed ;
15
+
10
16
/// <summary>
11
17
/// Application entry point method. Executes all data processors.
12
18
/// </summary>
Original file line number Diff line number Diff line change
1
+ namespace JQDT . Delegates
2
+ {
3
+ using JQDT . Models ;
4
+
5
+ /// <summary>
6
+ /// Occurs on data process event
7
+ /// </summary>
8
+ /// <param name="data">The data.</param>
9
+ /// <param name="requestInfoModel">The request information model.</param>
10
+ public delegate void DataProcessorEventHandler ( object data , RequestInfoModel requestInfoModel ) ;
11
+ }
Original file line number Diff line number Diff line change 80
80
<Compile Include =" DataProcessing\IDataProcessChain.cs" />
81
81
<Compile Include =" DataProcessing\SortDataProcessing\SortDataProcessor.cs" />
82
82
<Compile Include =" DataProcessing\PagingDataProcessing\PagingDataProcessor.cs" />
83
+ <Compile Include =" Delegates\DataProcessorEventHandler.cs" />
83
84
<Compile Include =" DI\DependencyResolver.cs" />
84
85
<Compile Include =" DI\IDependencyResolver.cs" />
85
86
<Compile Include =" Enumerations\OperationTypesEnum.cs" />
You can’t perform that action at this time.
0 commit comments