Hi, I have to create a table to monitor a list of streams.
The table, as you can see from the attached, must have the following features:
- The stream description (or name) to be monitored
- The type (input, output or both)
- The results of a particular day (and here is the problem)
It must also be possible:
- Switch the view from one week to another
- Change the type of streams to be displayed (View 1 for example shows the customer streams. The View 2 is for suppliers streams)
The data streams are provided by Web Service, via JSON.
I planned on doing everything with the RadGrid, but I have some difficulties in its implementation.
This is the model to pass:
1.
[DataContractFormat]
2.
public
class
StreamOutputDto : BaseDto
3.
{
4.
public
string
Name {
get
;
set
; }
5.
public
string
Type {
get
;
set
; }
6.
public
List<DetailStream> Details {
get
;
set
; }
7.
}
Where "DetailStream" is:
01.
public
class
DetailStream
02.
{
03.
public
string
Id {
get
;
set
; }
04.
public
DateTime Date {
get
;
set
; }
05.
public
int
CountInfo {
get
;
set
; }
06.
public
StateStream StateInput {
get
;
set
; }
07.
public
StateStream StateOutput {
get
;
set
; }
08.
//...
09.
}
10.
11.
public
enum
StateStream
12.
{
13.
InProgress,
14.
Received,
15.
Declined,
16.
Inexistent
17.
}
So DetailStream is the result of a specific stream in a specific day.
Details is a list of DetailStream, ie the results of a specific stream in a specific week.
With Name and Type there are no problems, but I do not know how to manage the list of DetailStream.
This is my current implementation:
My Web Service:
01.
[ServiceContract]
02.
public
interface
IMyService
03.
{
04.
[OperationContract]
05.
[WebInvoke(
06.
Method =
"POST"
,
07.
ResponseFormat = WebMessageFormat.Json)]
08.
StandardResponse<StreamOutputDto> GetStream(
string
request);
09.
}
10.
11.
12.
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]
13.
[MessageLoggingBehavior]
14.
public
class
MyService : IMyService
15.
{
16.
17.
public
StandardResponse<StreamOutputDto> GetStream(
string
request)
18.
{
19.
// TEST CASE:
20.
StandardResponse<StreamOutputDto> response =
new
StandardResponse<StreamOutputDto>();
21.
response.Output =
new
StreamOutputDto();
22.
response.Output.Name =
"Hi!"
;
23.
response.Output.Type =
"Input"
;
24.
response.Output.Details =
new
List<DetailStream>();
25.
26.
response.Output.Details.Add(
new
DetailStream(){
27.
Id =
"1"
,
28.
CountInfo = 100,
29.
Date = DateTime.Today });
30.
31.
response.Output.Details.Add(
new
DetailStream(){
32.
Id =
"2"
,
33.
// Date = yesterday,
34.
CountInfo = 200 });
35.
36.
return
response;
37.
}
38.
39.
}
My WebForm.aspx:
01.
<head>
02.
<script src=
"https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"
></script>
03.
<script src=
"RadGridParser.js"
></script>
04.
</head>
05.
06.
<body>
07.
08.
<telerik:RadScriptManager runat=
"server"
ID=
"RadScriptManager1"
/>
09.
<telerik:RadSkinManager ID=
"RadSkinManager1"
runat=
"server"
ShowChooser=
"true"
/>
10.
11.
<telerik:RadGrid ID=
"RadGrid1"
RenderMode=
"Lightweight"
ClientDataSourceID=
"RadClientDataSource1"
12.
AllowPaging=
"false"
AllowSorting=
"false"
AllowFilteringByColumn=
"false"
PageSize=
"5"
runat=
"server"
>
13.
14.
<MasterTableView DataKeyNames=
"Name"
ClientDataKeyNames=
"Name"
>
15.
<Columns>
16.
<telerik:GridBoundColumn DataField=
"Name"
HeaderText=
""
DataType=
"System.String"
>
17.
</telerik:GridBoundColumn>
18.
<telerik:GridBoundColumn DataField=
"Type"
HeaderText=
"Tipologia flusso"
DataType=
"System.String"
>
19.
</telerik:GridBoundColumn>
20.
<telerik:GridBoundColumn DataField=
"Day1"
HeaderText=
"Lunedì"
>
21.
</telerik:GridBoundColumn>
22.
<telerik:GridBoundColumn DataField=
"Day2"
HeaderText=
"Martedì"
>
23.
</telerik:GridBoundColumn>
24.
<telerik:GridBoundColumn DataField=
"Day3"
HeaderText=
"Mercoledì"
>
25.
</telerik:GridBoundColumn>
26.
<telerik:GridBoundColumn DataField=
"Day4"
HeaderText=
"Giovedì"
>
27.
</telerik:GridBoundColumn>
28.
<telerik:GridBoundColumn DataField=
"Day5"
HeaderText=
"Venerdì"
>
29.
</telerik:GridBoundColumn>
30.
</Columns>
31.
</MasterTableView>
32.
33.
</telerik:RadGrid>
34.
35.
<telerik:RadClientDataSource ID=
"RadClientDataSource1"
runat=
"server"
AllowBatchOperations=
"true"
>
36.
<ClientEvents OnCustomParameter=
"ParameterMap"
OnDataParse=
"Parse"
/>
37.
<DataSource>
38.
<WebServiceDataSourceSettings>
39.
<Select Url=
"http://soldev/Axa.Sol.Web/ws/Ivass/IvassService.svc/GetFlusso3"
DataType=
"JSON"
RequestType=
"Post"
/>
40.
</WebServiceDataSourceSettings>
41.
</DataSource>
42.
<Schema ResponseType=
"JSON"
>
43.
<Model ID=
"StreamModel"
>
44.
<telerik:ClientDataSourceModelField FieldName=
"Name"
DataType=
"String"
/>
45.
<telerik:ClientDataSourceModelField FieldName=
"Type"
DataType=
"String"
/>
46.
<telerik:ClientDataSourceModelField FieldName=
"Day1"
DataType=
"String"
/>
47.
<telerik:ClientDataSourceModelField FieldName=
"Day2"
DataType=
"String"
/>
48.
<telerik:ClientDataSourceModelField FieldName=
"Day3"
DataType=
"String"
/>
49.
<telerik:ClientDataSourceModelField FieldName=
"Day4"
DataType=
"String"
/>
50.
<telerik:ClientDataSourceModelField FieldName=
"Day5"
DataType=
"String"
/>
51.
</Model>
52.
</Schema>
53.
</telerik:RadClientDataSource>
54.
55.
</body>
My RadGridParser.js :
01.
//<![CDATA[
02.
function
ParameterMap(sender, args) {
03.
//If you want to send a parameter to the select call you can modify the if
04.
//statement to check whether the request type is 'read':
05.
//if (args.get_type() == "read" && args.get_data()) {
06.
if
(args.get_type() !=
"read"
&& args.get_data()) {
07.
args.set_parameterFormat({ request: kendo.stringify(args.get_data().models) });
08.
}
09.
}
10.
11.
function
Parse(sender, args) {
12.
var
response = args.get_response();
13.
if
(response) {
14.
args.set_parsedData(response.Output);
15.
}
16.
}
17.
18.
function
UserAction(sender, args) {
19.
if
(sender.get_batchEditingManager().hasChanges(sender.get_masterTableView()) &&
20.
!confirm(
"Any changes will be cleared. Are you sure you want to perform this action?"
)) {
21.
args.set_cancel(
true
);
22.
}
23.
}
24.
25.
//]]>