Is there a way I can creater my own custom functions that returns values in Reports?
eg,.
so in the field I just have to call
= GetValue(Field.myfield);
I know I can also use the IIF for this but in this specific solution i want to use my own customised function
eg,.
public string GetValue(int val) |
{ |
if(val == 1){ |
return "yes"; |
}else{ |
return "no"; |
} |
} |
= GetValue(Field.myfield);
I know I can also use the IIF for this but in this specific solution i want to use my own customised function
4 Answers, 1 is accepted
0
Accepted
Hi Stuart,
Yes you can do that, the only thing that you should have in mind is that user functions are public static (Public Shared in VB.NET) methods that always return a value and should always be a member of the respective report class. I've prepared a sample report for your convenience. Give it a spin and let us know if we can be of further help.
Greetings,
Steve
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
Yes you can do that, the only thing that you should have in mind is that user functions are public static (Public Shared in VB.NET) methods that always return a value and should always be a member of the respective report class. I've prepared a sample report for your convenience. Give it a spin and let us know if we can be of further help.
Greetings,
Steve
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
0

Stuart
Top achievements
Rank 1
answered on 18 Jun 2008, 02:05 PM
I am still using the Q3 2007 version of Telerik Reporting might this be the problem
I didnt put his in a class library it is inside a folder in the project itself
The path to the report class is |root|\Reports\Audit.cs
here is my Class code
And to call the code I use
=GetHAValue(Fields.A1)
but still get an error
I didnt put his in a class library it is inside a folder in the project itself
The path to the report class is |root|\Reports\Audit.cs
here is my Class code
namespace TNAClient.Reports |
{ |
using System.ComponentModel; |
using System.Drawing; |
using System.Windows.Forms; |
using Telerik.Reporting; |
using Telerik.Reporting.Drawing; |
/// <summary> |
/// Summary description for Report1. |
/// </summary> |
public partial class HealthAudit : Report |
{ |
string groupid; |
public HealthAudit(string groupid) |
{ |
this.groupid = groupid; |
/// <summary> |
/// Required for telerik Reporting designer support |
/// </summary> |
InitializeComponent(); |
repHead.Value = System.Drawing.Image.FromFile(System.IO.Path.GetFullPath(@"BluZebraLogo.jpg")); |
auditConnection.ConnectionString = @"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database\ClientDB.mdf;Integrated Security=True;User Instance=True"; |
healthAuditDataTableAdapter1.Connection = auditConnection; |
healthAuditDataTableAdapter1.FillBy(healthAuditData.HealthAuditDataTable , ""+groupid); |
} |
public static string GetHAValue(object val) |
{ |
int i = int.Parse(val.ToString()); |
if (i == 1) |
{ |
return "Never"; |
} |
else if (i == 2) |
{ |
return "Rarely"; |
} |
else if (i == 3) |
{ |
return "50% of Times"; |
} |
else if (i == 4) |
{ |
return "Mostly"; |
} |
else if(i ==5) |
{ |
return "Always"; |
} |
else |
{ |
return "N/A"; |
} |
} |
} |
} |
=GetHAValue(Fields.A1)
but still get an error
0

Stuart
Top achievements
Rank 1
answered on 18 Jun 2008, 02:26 PM
I saw my mistake , I tried parsing a null value to the static method. sorry problem solved
0
Hi Stuart,
I've modified the application I've send previously to represent the changes you mention. Still I get the proper behavior and the report is working correctly. Can you look into the modified application and see what differs in your case? What error do you get in yours?
Regards,
Steve
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
I've modified the application I've send previously to represent the changes you mention. Still I get the proper behavior and the report is working correctly. Can you look into the modified application and see what differs in your case? What error do you get in yours?
Regards,
Steve
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center