Plus parameter and page

Posted by: thinh.dao-dang on 13 June 2019, 6:04 pm EST

    • Post Options:
    • Link

    Posted 13 June 2019, 6:04 pm EST

    hi. i’m Thinh and i from VietNam, please answer me a question.

    when i get a parameter from preview sourcecode, so after

    i plus [page] with [prmPage]. but it not show anything

    rptSub1.Parameters[“prmPage”].Value = 10;

    rptSub1.Parameters[“prmTotalPage”].Value = 10;

    =>

    "Page " & [Page + CInt(prmPage)] & " / " & [Pages + CInt(prmTotalPage)]

    what can i do?

  • Posted 16 June 2019, 5:24 pm EST

    Hello,

    Assuming that you are using C1FlexReport, please inform about the use-case based on which you intend to use parameters for displaying page numbers.

    The below mentioned code can be used to set calculated page numbers in a TextField, at run-time:

    ```

    TextField tf = new TextField();

    tf = (TextField)c1FlexReport1.Fields[“ftrRight”];

    tf.Text.Expression= “"Page " & [Page] & " / " & [Pages]”;

    
    Further, values of parameters used in a report can be fetched as follows:
            ```
        c1FlexReport1.Parameters[0].Value = 10;
                Console.WriteLine(c1FlexReport1.Parameters[0].Value);
    

    Once a report has finished rendering, you can fetch the pages, as follows:

    ```

    private void c1FlexReport1_EndReport(object sender, EventArgs e)

    {

    Console.WriteLine(c1FlexReport1.PageCount);

    }

    Refer the attached application for the implementation.
    In case it does not help, please elaborate on the requirement so that I can assist you further.  
     
    Regards,
    Esha
    
    [zip filename="prj_FlexReport.zip"]https://gccontent.blob.core.windows.net/forum-uploads/file-67d70a27-1540-4a49-9268-b86ee6efa6c8.zip[/zip]
  • Posted 16 June 2019, 11:46 pm EST

    once more question,

    how to get Pages in previewSheet.cs ( function setData() )

  • Posted 17 June 2019, 3:14 pm EST

    Hi esha.dhir, thanks for support me.

    i did as follow, but i can’t get anything



    int pageDefaut = 10; // parameter

    TextField tf = new TextField();

    tf = (TextField)c1FlexReport1.Fields[“ftrRight”];

    tf.Text.Expression= “"Page " & pageDefaut + [Page] & " / " & pageDefaut + [Pages]”;



    becasue, i have 2 report, the first, report 1 print, and get pages of report 1,

    after, report 2 print with begin pages of report 1

    ex: report1 result page 10,

    => report 2 = 10 + page of now / 10 + pages of now.

    please help me, what can i do?

  • Posted 18 June 2019, 4:09 pm EST

    Hello,

    This expression is not correct as the value in [Pages] is generated after complete rendering of the report. Thus, this addition to a specific value will not work here for the page total.

    An alternative is to re-render the report so that we have a PageTotal in hand first. This can then be used to add to a default value and generate the expected results.

    The modified application showing the same is attached for your reference.

    Thanks.

    prj_FlexReport -Re_render.zip

  • Posted 18 June 2019, 6:48 pm EST

    HI esha.dhir, thansk for answer. but i have a wrong when run my example with your suggestions.

    private pageTotal = 0;

    c1FlexReport1_EndReport()

    pageTotal = c1FlexReport1.PageCount;

    c1FlexReport1_StartSection()

    if (e.Section == SectionTypeEnum.PageFooter)

    {

    TextField tf = new TextField();

    tf = (TextField)c1FlexReport1.Fields[“ftrRight”];

    int pageDefaut = 5; // parameter from report 1

    int total = pageTotal + pageDefaut;

    tf.Text = "Page " + (e.Page +pageDefaut) + “/” + total;

    }

    => Total of report 2 is not true. because Total variable only exit when report EndReport() function runed,

    => in StartSection() Total is only pages of report 1 anytime

    EX: report 1 return 5 pages

    report 2 is show: page 6/5 …->… page. 10/5

    where is wrong ?

  • Posted 18 June 2019, 8:57 pm EST

    Hi,

    Have you used report 2 as the same report instance?

    Note that I have called Render method twice in the button’s event handler:

     private void paraButton_Click(object sender, EventArgs e)
    {
    ....
    [b]  c1FlexReport1.Render();
    [/b]            //Render again. This time, the PageCount from the previous rendering is used to get the total page count and then add the default variable value to it.
    [b]           c1FlexReport1.Render();[/b]
     c1FlexViewer1.DocumentSource = c1FlexReport1;   
    }
    

    Did you do it in the same manner in your application?

    Thanks.

  • Posted 20 June 2019, 12:12 pm EST

    Hi esha.dhir.

    thanks for support me, exactly that’s right.

    my project run well.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels