2009-09-17 2 views
8

인사말.SSRS - 열을 동적으로 숨길 때 테이블을 동일한 너비로 유지 하시겠습니까?

나는 물건 가격을 보여주는 SSRS 2005 보고서를 가지고 있습니다. 일부 고객의 경우 표에서 열을 숨 깁니다 (Visibility - hidden 속성에 대한 표현식이 있음).

이렇게하면 내 테이블이 축소됩니다. 길고 열심히이 테이블의 크기를 동적으로 조정하는 방법을 찾았습니다 (또는 동일한 너비를 유지하기 위해 디자인 타임에 무언가를 할 수 있습니다).하지만 막혔습니다.

단순히 '당신이 할 수 없다'는 대답은 도움이되지 않습니다. 나는 이미 그것을 읽었습니다 : http://forums.asp.net/t/1354956.aspx

나는 SO 커뮤니티의 영리한 영혼이 나를위한 대안을 가지기를 바라고 있습니다. 감사!

+0

특정 열이 보이지 않을 때 전체 테이블을 포함하도록 모든 열의 크기를 조정 하시겠습니까? – shahkalpesh

+0

그게 효과가있다. 열의 1 또는 2 크기를 조정하면 해결할 수 있습니다. 테이블이 너비가 같을뿐입니다. – JoeB

답변

6

이 작업을 수행하는 방법을 알고있는 유일한 방법은 런타임 중에 RDLC 파일을 변경하는 것입니다. 기본적으로 RLDC 파일을 메모리 (XML 파일)에로드하고 테이블 너비를 포함하는 XML 노드를 찾은 다음 메모리의 설정을 수정할 수 있습니다. 이 작업을 완료하면 메모리에로드 된 RDLC 파일을 사용하여 reportViewer 컨트롤을 새로 고칠 수 있습니다.

그리고 예, 이미이 작업을 수행했으며 작동합니다.

--- EDIT --- 다음 코드 예제는 XMLpath를 통해 메모리에있는 RDLC 파일의 데이터를 변경하는 것입니다.

Private Sub ModifyRDLCInMemory() 

    Dim xmlDoc As XmlDocument = New XmlDocument 
    Dim asm As Reflection.Assembly = Reflection.Assembly.GetExecutingAssembly() 
    'create in memory, a XML file from a embedded resource 
    Dim xmlStream As Stream = asm.GetManifestResourceStream(ReportViewer1.LocalReport.ReportEmbeddedResource) 

    Try 
     'Load the RDLC file into a XML doc 
     xmlDoc.Load(xmlStream) 
    Catch e As Exception 
     MessageBox.Show(e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1) 
    End Try 

    'Create an XmlNamespaceManager to resolve the default namespace 
    Dim nsmgr As XmlNamespaceManager = New XmlNamespaceManager(xmlDoc.NameTable) 
    nsmgr.AddNamespace("nm", "http://schemas.microsoft.com/sqlserver/reporting/2005/01/reportdefinition") 
    nsmgr.AddNamespace("rd", "http://schemas.microsoft.com/SQLServer/reporting/reportdesigner") 

    'Loop through each node in the XML file 
    Dim node As XmlNode 
    For Each node In xmlDoc.DocumentElement.SelectNodes(String.Format("//nm:{0}[@rd:LocID]", "Value"), nsmgr) 'XPath to LocID node.. You will want to change this to locate your Table Width node. You may need to read up on XMLPath 
     Dim nodeValue As String = node.InnerText 'Gets current value of Node 
     If (String.IsNullOrEmpty(nodeValue) Or Not nodeValue.StartsWith("=")) Then 
     Try 
      node.InnerText = YOURNEWVALUE 

     Catch ex As Exception 
      'handle error 
     End Try 
     End If 
    Next 

    ReportViewer1.LocalReport.ReportPath = String.Empty 
    ReportViewer1.LocalReport.ReportEmbeddedResource = Nothing 
    'Load the updated RDLC document into LocalReport object. 
    Dim rdlcOutputStream As StringReader = New StringReader(xmlDoc.DocumentElement.OuterXml) 
    Using rdlcOutputStream 
     ReportViewer1.LocalReport.LoadReportDefinition(rdlcOutputStream) 
    End Using 

    End Sub 
+1

문제는 매우 흥미 롭습니다. 나는 한 시간 정도 더주고, 아무도 더 나은 해결책을 찾지 못하면 당신을 대답으로 표시 할 것입니다. 감사! – JoeB

+0

당신이 원한다면 나는 당신을 도울 수있는 몇 가지 VB.NET 코드가 있습니다. 나는 지금 실제로 할 것입니다. – jgallant

+0

코드 게시 됨. 그것에 대해 궁금한 점이 있으면 알려주십시오. 우리는이 방법으로 보고서를 현지화하는 데 사용되었습니다 (언어가 전환되었을 때 데이터 변경). 이제 보고서가 동적으로 생성되므로 더 이상이 보고서를 사용하지 않습니다. – jgallant

관련 문제