I am very new to Telerik Reporting as well as MVC. I am using Telerik Reporting Q1 2013 and MVC 4. I want to pass some info as parameter to report. I tried by sending parameter from code behind of report, but no use. It showing all record.
What I have done is
public partial class ImmunizationRpt : Telerik.Reporting.Report
{
public ImmunizationRpt()
{
InitializeComponent();
Telerik.Reporting.ReportParameter param = new ReportParameter();
param.Name = "PatientKey";
param.Type = ReportParameterType.Integer;
param.AllowBlank = false;
param.AllowNull = false;
param.Value = 1;
param.Visible = true;
this.Report.ReportParameters.Add(param);
//this.Report.ReportParameters.Add("PatientKey",ReportParameterType.Integer,1);
}
}
If the parameter is already defined in the report, you can access it through the collection.
this.Report.ReportParameters["PatientKey"].Value = 1;
thank you for reply! i have achived this as
my report was showing all records, because i hadn't set the report to filter the records based on the parameter value. To achieve that, first we need to add the new parameter from the code behind (as i did) and then we need to add a new filter as shown in the following code:
Telerik.Reporting.Filter filter1 = new Telerik.Reporting.Filter();
filter1.Expression = "=Fields.PatientKey";
filter1.Operator = Telerik.Reporting.FilterOperator.Equal;
filter1.Value = "=Parameters.PatientKey.Value";
report.Filters.Add(filter1);
Related
My ASP.Net Core RDLC Report is working fine but tried to hide row when the field value is zero by right click the rdlc report row and then click Row Visibility. In the Row Visibility dialog box I selected Show Or Hide based on an Expression Under Change display options and used this expression
IIf(Fields!StudentAmt.Value=0,True,False)
and got the following error.
ReportProcessingException: An unexpected error occurred while compiling expressions. Native compiler return value: ‘[BC30390] 'AspNetCore.ReportingServices.RdlExpressions.ExpressionHostObjectModel.DataRegionExprHost(Of TMemberType, TCellType).m_memberTreeHostsRemotable' is not accessible in this context because it is 'Friend
I am using Reference of AspNetCore.Reporting for local Report
And this Second Error displayed as a result of this expression Format(Fields!OEndDate.Value, "MMM-yyyy")
IndexOutOfRangeException: Index was outside the bounds of the array.
My Controller
public IActionResult Report()
{
string mimtype = "";
int extension = 1;
Dictionary<string, string> parameters = new Dictionary<string, string>
{
{ "rpl", “Student Name” }
};
LocalReport localReport = new LocalReport(mypath);
localReport.AddDataSource("DataSet1", mydatasource);
var result = localReport.Execute(RenderType.Pdf, extension, parameters, mimtype);
return File(result.MainStream, "application/pdf");
}
Are you using AspNetCore.Reporting? Do not use any expressions, report will fail. This is limitation of this library.
If you wish to hide rows using the expression, I recommend you to use ReportViewerCore.NETCore.
Below is my test, you can refer to it:
public IActionResult Report()
{
var test = _context.Table.ToList();
var path = $"{_webHostEnvironment.WebRootPath}\\Reports\\Report2.rdlc";
LocalReport report = new LocalReport();
report.ReportPath= path;
report.DataSources.Add(new ReportDataSource("DataSet1", test));
report.SetParameters(new[] { new ReportParameter( "rdl", "Student Name" ) });
byte[] pdf = report.Render("PDF");
return File(pdf, "application/pdf");
}
Before using the expression:
After using the expression:
Output Result:
More details about ReportViewerCore.NETCore, you can refer to this link.
Your second error may just be a problem with data loading, you can refer to this link to solve it.
I am working in CRM 2013 where i need to set a date of my textbox and save it to CRM 2013 database.
look at my code :
var CRMForm = document.parentWindow.parent.Xrm.Page;
var currentDateTime = new Date();
CRMForm.getAttribute("date").setValue(currentDateTime);
But i am getting an exception here : Out of stack space
Are you working on a form or on a custom Web resource?
I'm getting confused because you are getting the parent form,
var currentDateTime = new Date();
Xrm.Page.getAttribute("requestdeliveryby").setValue(currentDateTime);
This should be more than enough. Remember that you need to register it properly when you edit the form:
Properties->Events->OnLoad ? Looking at your example looks like you are trying to get the Xrm namespace from the wrong form.
Got the solution myself and its as following :
var dt= CRMForm.getAttribute("date");
if(dt.getValue() != null)
{
dt.setValue(dt.getValue().setFullYear(currentDateTime.getFullYear()));
dt.setValue(dt.getValue().setDate(currentDateTime.getDate()));
dt.setValue(dt.getValue().setMonth(currentDateTime.getMonth()));
}
I saw a related question:
Sitecore Glass Mapper always null
But unfortunately it does not give a solution for my case.
Here goes a code snippet:
var db = Factory.GetDatabase("master");
var context = new SitecoreContext();
// the ID of Needed item
var g = new Guid("{F21C04FE-8826-41AB-9F3C-F7BDF5B35C76}");
// just to test if it's possible to fetch item using db.GetItem
var i = db.GetItem(new ID(g), Language.Current, Sitecore.Data.Version.Latest);
// Grab item
var t = context.GetItem<Article>(g);
In the code above:
i is not null
t is null
Article is the simple class like:
[SitecoreType(TemplateId = "{4C4EC1DA-EB77-4001-A7F9-E4C2F61A9BE9}")]
public class Article
{
[SitecoreField(FieldName = "Title")]
public string Title { get; set; }
}
There are only one language installed in Sitecore - en, it has been specified in the web.config in the items as well.
Also I have added GlassMapperSc.Start(); to Application_Start in the Global.asax.cs and added my assembly to the list of included assemblies via var attributes = new AttributeConfigurationLoader(new[] { "Assembly.Name" }); and I succeeded to find my class in the SitecoreContext mappings.
It does not looks like a language issue, as stated in the link provided in the very beginning. And I'm struggling with it already for a pretty long time, but no luck...
Thank You!
I just noticed that you are using master db for the Sitecore DB and SitecoreContext for Glass.
The SitecoreContext class will use the database that is defined by the Sitecore.Context.Database property at runtime. This probably means that it is using the web database.
Can you check that you have published the item to the web database or instead using:
var context = new SitecoreService("master");
i want to pass Log ind person id as parameter to telerik report Q1 2013 using mvc 4 vs 2012.and i don't want send parameter through UI parameter.
what i have done on aspx view is
<script runat="server">
public override void VerifyRenderingInServerForm(Control control)
{
// to avoid the server form (<form runat="server"> requirement
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
var report = new ImmunizationRpt();
var instanceReportSource = new Telerik.Reporting.InstanceReportSource();
instanceReportSource.ReportDocument = report;
report.ReportParameters.Add("PatientKey",Telerik.Reporting.ReportParameterType.Integer, 1);
ReportViewer1.ReportSource = instanceReportSource;
ReportViewer1.RefreshReport();
}
</script>
but report shows all record.it not getting filter record.
my report was showing all records, because i hadn't set the report to filter the records based on the parameter value. To achieve that, first we need to add the new parameter from the code behind (as i did) and then we need to add a new filter as shown in the following code:
Telerik.Reporting.Filter filter1 = new Telerik.Reporting.Filter();
filter1.Expression = "=Fields.PatientKey";
filter1.Operator = Telerik.Reporting.FilterOperator.Equal;
filter1.Value = "=Parameters.PatientKey.Value";
report.Filters.Add(filter1);
I need merely a readonly display of Linq data; no requirement to observe changes. Here's the Linq:
string ZIPCODEFIELDNAME="zip5";
DataTable DATA = (detailedQueryResult as DataTable);
IEnumerable<object> ZIPCODE_SUMMARY;
ZIPCODE_SUMMARY = from z in DATA.AsEnumerable()
group z by z.Field<string>(ZIPCODEFIELDNAME) into g
let list = g.ToList()
select new
{
zip = g.Key,
eecount = list.Count(),
// possible additional aggregate columns here
};
I am able to bind this IEnumerable<anonymous object> to a Telerik RadGridView in code-behind simply by doing this:
myRadGridView.ItemsSource = ZIPCODE_SUMMARY.ToList();
that is, without having to declare a binding in XAML or having to define any columns. How would that be accomplished using the WPF DataGrid that ships with Visual Studio? It displays only row separators when I use the identical approach. So it knows about the items in the list, just not how to fetch the columns.
I am trying to write some quick-and-dirty utilities to import a gazillion CSV files where no two of them have the same structure or same field names, and the fewer lines of setup code the better.
P.S. I am just getting into WPF and Linq, so please set ReplyToNovice=true :-)
Did you remember to set AutoGenerateColumns=true on the datagrid? If yes, try binding to an ICollectionView instead.
UPDATE:
Thats weird, the code below works fine for me. One thing though, you may have to set the datacontext of the datagrid to {Binding}, this will bind to the whole object.
public MainWindow()
{
InitializeComponent();
dgZips.ItemsSource = GetFakeZips();
}
public dynamic GetFakeZips()
{
return Enumerable.Range(1500, 10).Select(i => new { Zip = i, Count = i / 4 });
}
Xaml:
<DataGrid x:Name="dgZips" AutoGenerateColumns="True" />