This is a migrated thread and some comments may be shown as answers.

Accessing trdx file parameters

2 Answers 155 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Alain
Top achievements
Rank 1
Alain asked on 24 Nov 2015, 09:24 PM

I have this HTML code:

@(Html.TelerikReporting().ReportViewer()
    .Id("reportViewer")
.ServiceUrl(Url.Content("~/api/reports/"))
.TemplateUrl(Url.Content("~/ReportViewer/templates/telerikReportViewerTemplate-9.2.15.930.html"))
.ReportSource("Coordinaciones/Report1.trdx", new Dictionary<string, object>() { { "@Daes_id", "DAE011" } })
.ViewMode(ViewMode.Interactive)
.ScaleMode(ScaleMode.Specific)
.Scale(1.0)
.PersistSession(false)
.PrintMode(PrintMode.AutoSelect)
.ParametersAreaVisible(false)

2 Answers, 1 is accepted

Sort by
0
Alain
Top achievements
Rank 1
answered on 24 Nov 2015, 09:32 PM

Sorry, I have this HTML code:

@(Html.TelerikReporting().ReportViewer()
    .Id("reportViewer")
.ServiceUrl(Url.Content("~/api/reports/"))
.TemplateUrl(Url.Content("~/ReportViewer/templates/telerikReportViewerTemplate-9.2.15.930.html"))
.ReportSource("Coordinaciones/Report1.trdx", new Dictionary<string, object>() { { "@Daes_id", "DAE011" } })
.ViewMode(ViewMode.Interactive)
.ScaleMode(ScaleMode.Specific)
.Scale(1.0)
.PersistSession(false)
.PrintMode(PrintMode.AutoSelect)
.ParametersAreaVisible(false)

And I have this sql command on the trdx report

SELECT
[Daes].[numeroDae], 
[Daes].[id]
FROM [Daes]
WHERE [Daes].[id] = @Daes_id

 

And this is the trdx file code:

 <?xml version="1.0" encoding="utf-8"?>
<Report DataSourceName="sqlDataSource1" Width="16cm" Name="Report1" SnapGridSize="0.1cm" xmlns="http://schemas.telerik.com/reporting/2012/3.8">
  <DataSources>
    <SqlDataSource ConnectionString="LagReports" SelectCommand="SELECT&#xD;&#xA;&#x9;[Daes].[numeroDae], &#xD;&#xA;&#x9;[Daes].[id]&#xD;&#xA;FROM [Daes]&#xD;&#xA;WHERE [Daes].[id] = @Daes_id" Name="sqlDataSource1" QueryDesignerState="&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-16&quot;?&gt;&lt;DM xmlns:z=&quot;http://schemas.microsoft.com/2003/10/Serialization/&quot; xmlns:i=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xmlns=&quot;http://schemas.datacontract.org/2004/07/Telerik.Reporting.Design.QueryDesigner&quot;&gt;&lt;Es&gt;&lt;E z:Id=&quot;i1&quot;&gt;&lt;MBN&gt;Daes&lt;/MBN&gt;&lt;MBP z:Id=&quot;i2&quot; i:type=&quot;Namespace&quot;&gt;&lt;MBN&gt;&lt;/MBN&gt;&lt;MOC&gt;&lt;MB z:Ref=&quot;i1&quot; /&gt;&lt;/MOC&gt;&lt;/MBP&gt;&lt;MOC&gt;&lt;MB z:Id=&quot;i3&quot; i:type=&quot;P&quot;&gt;&lt;MBN&gt;id&lt;/MBN&gt;&lt;MBP z:Ref=&quot;i1&quot; /&gt;&lt;PO&gt;true&lt;/PO&gt;&lt;/MB&gt;&lt;MB z:Id=&quot;i4&quot; i:type=&quot;P&quot;&gt;&lt;MBN&gt;numeroDae&lt;/MBN&gt;&lt;MBP z:Ref=&quot;i1&quot; /&gt;&lt;PO&gt;true&lt;/PO&gt;&lt;/MB&gt;&lt;/MOC&gt;&lt;ER /&gt;&lt;/E&gt;&lt;/Es&gt;&lt;Fs&gt;&lt;F&gt;&lt;Op&gt;Equals&lt;/Op&gt;&lt;Pn&gt;@Daes_id&lt;/Pn&gt;&lt;Py z:Ref=&quot;i3&quot; /&gt;&lt;Ve&gt;DAE012&lt;/Ve&gt;&lt;/F&gt;&lt;/Fs&gt;&lt;Ps&gt;&lt;P z:Ref=&quot;i4&quot; /&gt;&lt;P z:Ref=&quot;i3&quot; /&gt;&lt;/Ps&gt;&lt;Rs /&gt;&lt;/DM&gt;">
      <Parameters>
        <SqlDataSourceParameter DbType="String" Name="@Daes_id" />
      </Parameters>
    </SqlDataSource>
  </DataSources>
  <Items>
    <PageHeaderSection Height="2cm" Name="pageHeaderSection1" />
    <DetailSection Height="5cm" Name="detailSection1">
      <Items>
        <TextBox Width="3.00000010093053cm" Height="0.999999899069471cm" Left="5.59999959627788cm" Top="1.10000005046526cm" Value="= Fields.numeroDae" Name="textBox1" />
      </Items>
    </DetailSection>
    <PageFooterSection Height="2cm" Name="pageFooterSection1" />
  </Items>
  <StyleSheet>
    <StyleRule>
      <Style>
        <Padding Left="2pt" Right="2pt" />
      </Style>
      <Selectors>
        <TypeSelector Type="TextItemBase" />
        <TypeSelector Type="HtmlTextBox" />
      </Selectors>
    </StyleRule>
  </StyleSheet>
  <PageSettings>
    <PageSettings PaperKind="A4" Landscape="False" ColumnCount="1" ColumnSpacing="0cm">
      <Margins>
        <MarginsU Left="2cm" Right="2cm" Top="2cm" Bottom="2cm" />
      </Margins>
    </PageSettings>
  </PageSettings>
</Report>

 

When i called the view with teleric reporting, it not shows any data. Without parameters works fine. So I'm wondering what i'm not doing wright. Any help will be aprecciated.

0
Nasko
Telerik team
answered on 27 Nov 2015, 10:35 AM
Hello Alain,

Report parameter values should be passed via the Parameters collection of the report source:
@{
    var reportSource = new Telerik.Reporting.UriReportSource();
    reportSource.Uri = "MyReport.trdx";
    reportSource.Parameters.Add("Parameter1", "value");
}
 
@(Html.TelerikReporting().ReportViewer()
       .Id("reportViewer1")
       .ServiceUrl("/api/reports/")
       .TemplateUrl("/ReportViewer/templates/telerikReportViewerTemplate.html")
       .ReportSource(reportSource)
       .ViewMode(ViewMode.Interactive)
       .ScaleMode(ScaleMode.Specific)
       .Scale(1.0)
       .PersistSession(false)
       .Deferred()
       )

Additional information can be found in the MVC Report Viewer Manual Setup help article.

Regards,
Nasko
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
General Discussions
Asked by
Alain
Top achievements
Rank 1
Answers by
Alain
Top achievements
Rank 1
Nasko
Telerik team
Share this question
or