Announcement

Collapse
No announcement yet.

How to Insert a custom line as the first row and last row in the Grid?

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to Insert a custom line as the first row and last row in the Grid?

    Hi, I am using Grid for displaying a Cash Ledger for a financial accounting program. I need the Opening Balance to be displayed as the first line. I have used on record event and echo statement but this is just printing before the grid header. I want this to be under the grid header and also wanted to align to the first field? I am attaching a screen shot if my requirement is not clear.

    Thank you for your help

    Regards
    Narayanan

    Current Image Expected

  • #2
    Ok. After researching a lot I have solved this issue of Opening Balance. I am including here so that it might benefit someone who needs it. I have a global variable to figure out first time the record is getting printed. The following code is included in the onRecord event of the grid

    if ([first_time]==1)
    {
    [first_time] = 0;

    $prev_tran_bal = calc_op_bal();
    [opbal] = [opbal] + $prev_tran_bal;
    {close_bal} = [opbal];
    [cbal] = {close_bal};

    if ([opbal] >= 0 ) //Debit Balance
    {
    $first_line = "<td rowspan='1' class='scGridFieldOddFont css_tran_id_grid_line' style='' valign='' nowrap='' height='0px' align=''><span id='id_sc_field_tran_id_0'></span></td>
    <td rowspan='1' class='scGridFieldOddFont css_tran_date_grid_line' style='' valign='' nowrap='' height='0px' align=''><span id='id_sc_field_tran_date_0'></span></td>
    <td rowspan='1' class='scGridFieldOddFont css_particulars_grid_line' style='' valign='' height='0px' align=''><span id='id_sc_field_particulars_0'><b>Opening Balance</b></span></td>
    <td rowspan='1' class='scGridFieldOddFont css_db_amount_grid_line' style='' valign='' height='0px' align=''><span id='id_sc_field_db_amount_0'>";
    $conteudo = NM_encode_input(sc_strip_script($this->sc_temp_cbal));
    nmgp_Form_Num_Val($conteudo, $_SESSION['scriptcase']['reg_conf']['grup_val'], $_SESSION['scriptcase']['reg_conf']['dec_val'], "2", "S", "2", $_SESSION['scriptcase']['reg_conf']['monet_simb'], "V:" . $_SESSION['scriptcase']['reg_conf']['monet_f_pos'] . ":" . $_SESSION['scriptcase']['reg_conf']['monet_f_neg'], $_SESSION['scriptcase']['reg_conf']['simb_neg'], $_SESSION['scriptcase']['reg_conf']['unid_mont_group_digit']) ;

    $first_line = $first_line . "<b>" . $conteudo . "</b>";
    $first_line = $first_line . "</span></td>
    <td rowspan='1' class='scGridFieldOddFont css_cr_amount_grid_line' style='' valign='' height='0px' align=''><span id='id_sc_field_cr_amount_0'></span></td>
    <td rowspan='1' class='scGridFieldOddFont css_close_bal_grid_line' style='' valign='' height='0px' align=''><span id='id_sc_field_close_bal_0'></span></td>";
    echo $first_line;
    }
    else
    {
    // Credit Balance

    $first_line = "<td rowspan='1' class='scGridFieldOddFont css_tran_id_grid_line' style='' valign='' nowrap='' height='0px' align=''><span id='id_sc_field_tran_id_0'></span></td>
    <td rowspan='1' class='scGridFieldOddFont css_tran_date_grid_line' style='' valign='' nowrap='' height='0px' align=''><span id='id_sc_field_tran_date_0'></span></td>
    <td rowspan='1' class='scGridFieldOddFont css_particulars_grid_line' style='' valign='' height='0px' align=''><span id='id_sc_field_particulars_0'><b>Opening Balance</b></span></td>
    <td rowspan='1' class='scGridFieldOddFont css_db_amount_grid_line' style='' valign='' height='0px' align=''><span id='id_sc_field_db_amount_0'>";
    $conteudo = NM_encode_input(sc_strip_script($this->sc_temp_cbal)) * -1;
    nmgp_Form_Num_Val($conteudo, $_SESSION['scriptcase']['reg_conf']['grup_val'], $_SESSION['scriptcase']['reg_conf']['dec_val'], "2", "S", "2", $_SESSION['scriptcase']['reg_conf']['monet_simb'], "V:" . $_SESSION['scriptcase']['reg_conf']['monet_f_pos'] . ":" . $_SESSION['scriptcase']['reg_conf']['monet_f_neg'], $_SESSION['scriptcase']['reg_conf']['simb_neg'], $_SESSION['scriptcase']['reg_conf']['unid_mont_group_digit']) ;
    $first_line = $first_line . "</span></td>
    <td rowspan='1' class='scGridFieldOddFont css_cr_amount_grid_line' style='' valign='' height='0px' align=''><span id='id_sc_field_cr_amount_0'>";
    $first_line = $first_line . "<b>" . $conteudo . "</b>";
    $first_line = $first_line . "</span></td>
    <td rowspan='1' class='scGridFieldOddFont css_close_bal_grid_line' style='' valign='' height='0px' align=''><span id='id_sc_field_close_bal_0'></span></td>";
    echo $first_line;
    }
    }

    Comment


    • #3
      I have one problem in the above approach.This works perfect for the screen but this does not get printed in the PDF. I dont know why whatever is shown in PDF is not getting printed. Also the closing balance calculation is coming wrong in the PDF.

      Comment


      • #4
        A better solution would be a row that evaluate the opening balance added to the detail view. you ca do that with a UNION clause.
        Giorgio Bravi
        Dolphin Software & Thinkware

        Comment


        • #5
          Hi Narayanan
          Why not try to manage this on the grid datasource? Just add a row with Opening Balance ( using a UNION clause )
          Giorgio Bravi
          Dolphin Software & Thinkware

          Comment

          Working...
          X