views:

106

answers:

1

Hi,

I have the following code:

    $(document).ready(function() {
        var id = 'cbx';
        var idPrefix = 'Arrow';
        var html = '<img .../>';

            // query parent row
            var rowq = $('#' + id);
            if (rowq.length < 1) {
                rowq = $('.' + id);
                VersionHeader = true;
            }
            if (rowq[0]) {

                rowq.addClass('ArrowHeader');
                // set to 0 for header
                var index = 0;

                var row = rowq.parents('.g')[0].insertRow(index);
                // assign id for new row
                row.id = idPrefix + id;
                // assign classes for style and tree
                row.className = 'srcrow' + id;
                // insert new cell
                var cell = row.insertCell(0);
                // assign html result
                cell.innerHTML = html;
                // set colspan
                cell.colSpan = 1;

Now my problem is it adds the cell but it adds it under the first column. Is there a way to move through the columns? Granted I'm not an html expert at all. Just a beginner trying to get some stuff to work and would appreciate some help since I'm totally lost. I didn't include the html just ... through it.

Thanks

+3  A: 

I'm not sure I'm understanding your question entirely correctly (I gather you are attempting to insert a cell into a new row, and you want to select into which column it is inserted?). Assuming that's what you meant:

row.insertCell(0)

This is your problem. The insertCell method takes as an argument the index of the column into which the cell should be inserted. Index 0 is the first column, index 1 is the second column, and so on. So try replacing the 0 with the appropriate index.

Nick Lewis
When I put 4 in which is correct column but I get the following error:htmlfile: Invalid argument. That sounds correct but I'm not sure why I'm getting that error if that column is displayed.
Bruce227
-1 also works in the insertCell method. I would imagine it is for which cell but -1 doesn't seem to support that.
Bruce227