Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
334
Problem with Fixed Header
posted

Hi,

I would like to use a fixed header on my grid. However, when I set a column to fixedheader = true, I get an error on my javascript, which calculates the sum of a column.

My javascript code:

 function total_footer(gridID)
        {
            var rows = igtbl_getGridById(gridID).Rows;
            var vlr_total = 0;
            for (var i = 0; i < rows.length; i++) {
                vlr_unit = rows.getRow(i).getCellFromKey('valor_cheque').getValue();
                if (vlr_unit != null) {
                    vlr_unit = converter_valor(vlr_unit);
                    if (!isNaN(vlr_unit))
                        vlr_total += parseFloat(vlr_unit);
                }
            }
            if (rows.getRow(0) != null)
                rows.getRow(0).getCell(0).Element.parentNode.parentNode.nextSibling.childNodes[0].childNodes[15].innerHTML = "<nobr><b>" + formatCurrency(vlr_total) + "</b></nobr>";
}

The error:  nextSinbling.childNodes.0.childNodes.15 is null or not an object.

Taking this opportunity, I would like also to ask how to reffer to a grid column by column key rather than column index, as I have done in the example that follows (childNodes[15]:

rows.getRow(0).getCell(0).Element.parentNode.parentNode.nextSibling.childNodes[0].childNodes[15].innerHTML =
"<nobr><b>" + formatCurrency(vlr_total) + "</b></nobr>"

  • 45049
    posted

    I'm not sure what this line of code is attempting to refer to, so I can't tell whether the result you're getting should be expected:

    duanbrito said:
    rows.getRow(0).getCell(0).Element.parentNode.parentNode.nextSibling.childNodes[0].childNodes[15].innerHTML = "<nobr><b>" + formatCurrency(vlr_total) + "</b></nobr>";

    Once you get to "rows.getRow(0).getCell(0).Element", you're looking at HTML elements.  These will vary from browser to browser.

    What are you attempting to accomplish with this line of code?  From your follow-up question, I suspect that you're trying to get at a specific cell in row 0 through its HTML elements, when what you likely want to do is to get at the cell based on either the column index or column key.  You might instead be attempting to access the column's header text or footer text.