Marin, starting from there I have changed again my source. In this way the code works, is much clear then before, but I don't understand some things... I have find a way to use objects in the ClientDataSource
My code now is this:
Model and web service are the sames.(I have just added some properties to the model..)
My WebForm.aspx:
- the columns of the RadGrid:
<
Columns
>
<
telerik:GridBoundColumn
DataField
=
"Name"
HeaderText
=
""
DataType
=
"System.String"
>
</
telerik:GridBoundColumn
>
<
telerik:GridTemplateColumn
DataField
=
"Type"
HeaderText
=
"Tipologia flusso"
>
<
ClientItemTemplate
>
<
span
>#=showTipoFlusso(Type)#</
span
>
</
ClientItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
DataField
=
"DayLun"
HeaderText
=
"Lunedì"
>
<
ClientItemTemplate
>
#=showDetails(DayLun.Input, DayLun.Output, DayLun.Count)#
</
ClientItemTemplate
>
</
telerik:GridTemplateColumn
>
...
<
telerik:GridTemplateColumn
DataField
=
"DayVen"
HeaderText
=
"Venerdì"
>
<
ClientItemTemplate
>
#=showDetails(DayVen.Input, DayVen.Output, DayVen.Count)#
</
ClientItemTemplate
>
</
telerik:GridTemplateColumn
>
</
Columns
>
- the schema of RadClientDataSource:
<
Model
>
<
telerik:ClientDataSourceModelField
FieldName
=
"NomeFlusso"
DataType
=
"String"
OriginalFieldName
=
"NomeFlusso"
/>
<
telerik:ClientDataSourceModelField
FieldName
=
"TipoFlusso"
DataType
=
"Number"
/>
<%-- DON'T PUT OBJECTS DECLARED in Parse( ) function!
<
telerik:ClientDataSourceModelField
FieldName
=
"DayLun"
/>
<
telerik:ClientDataSourceModelField
FieldName
=
"DayMar"
/>
<
telerik:ClientDataSourceModelField
FieldName
=
"DayMer"
/>
<
telerik:ClientDataSourceModelField
FieldName
=
"DayGio"
/>
<
telerik:ClientDataSourceModelField
FieldName
=
"DayVen"
/>--%>
</
Model
>
My RadGridParser.js:
//<![CDATA[
function
ParameterMap(sender, args) {
if
(args.get_type() !=
"read"
&& args.get_data()) {
args.set_parameterFormat({ request: kendo.stringify(args.get_data().models) });
}
}
function
Parse(sender, args) {
var
output = args.get_response().Output;
if
(output) {
var
model = {
NomeFlusso: output.NomeFlusso,
CodCompagnia: output.CodCompagnia,
TipoFlusso: output.TipoFlusso,
DayLun: {
Id: output.DayLun.Id,
Count: output.DayLun.CountScarti,
Data: output.DayLun.Data,
Input: output.DayLun.StatoFlussoInput,
Output: output.DayLun.StatoFlussoOutput
},
DayMar: {
Id: output.DayMar.Id,
Count: output.DayMar.CountScarti,
Data: output.DayMar.Data,
Input: output.DayMar.StatoFlussoInput,
Output: output.DayMar.StatoFlussoOutput
},
DayMer: {
Id: output.DayMer.Id,
Count: output.DayMer.CountScarti,
Data: output.DayMer.Data,
Input: output.DayMer.StatoFlussoInput,
Output: output.DayMer.StatoFlussoOutput
},
DayGio: {
Id: output.DayGio.Id,
Count: output.DayGio.CountScarti,
Data: output.DayGio.Data,
Input: output.DayGio.StatoFlussoInput,
Output: output.DayGio.StatoFlussoOutput
},
DayVen: {
Id: output.DayLun.Id,
Count: output.DayVen.CountScarti,
Data: output.DayVen.Data,
Input: output.DayVen.StatoFlussoInput,
Output: output.DayVen.StatoFlussoOutput
}
};
args.set_parsedData(model);
}
}
function
UserAction(sender, args) {
if
(sender.get_batchEditingManager().hasChanges(sender.get_masterTableView()) &&
!confirm(
"Any changes will be cleared. Are you sure you want to perform this action?"
)) {
args.set_cancel(
true
);
}
}
/////////////////////////////
// Stream Details functions:
function
showTipoFlusso(value) {
// ...
// return the correct string: "INPUT" or "OUTPUT" or "IN / OUT"
}
function
showDetails(input, output, num) {
//...
// return the corrects html tags...
return
tags;
}
//]]>
How you can see, I have done a lot of changes. The parser is better, I don't have a lot of field.
My question is: way if I put something like:
<telerik:ClientDataSourceModelField FieldName="DayLun" />
in <Model> tag this doesn't works, but
<telerik:ClientDataSourceModelField FieldName="NomeFlusso" DataType="String" />
works? I don't understand.
If you need the rest of my code, just ask.