Skip to content Skip to sidebar Skip to footer

Adding Table Header And Footer With Jquery

I have a combo box which generates data bind to combo box as tables I want to add header and footer for the multi column combobox and also trying to freeze header and footer. Pl

Solution 1:

$('body').empty();

var tempDataMain = [];
tempDataMain.push($('<div />').append($('<table />').attr({ 'id': 'tblComboList', 'cellpadding': '0px', 'cellspacing': '0px', 'width': '319px' })).html());
tempDataMain.push('<thead><tr><td>Account Name</td><td>Account Number</td><td>Agreement Number</td></tr></thead>');
tempDataMain.push('<tbody>');

$.each(ctrl.dropDown.$items, function (i, item) {
    //tempDataMain.push('<tr><td colspan="3">' + i + ' items</td></tr>');

    var $tr = $('<tr/>');
    $.each(e.displayFields, function (j, displayField) {
        var $td = $('<td/>').text(e.data[i][displayField.fieldName]);

        if (displayField.style != undefined && displayField.style != null) {
            $td.attr('style', displayField.style);
        }
        $tr.append($td.css('white-space', 'nowrap'));
    });

    tempDataMain.push($('<div />').append($tr).html());
});

tempDataMain.push('</tbody>');
tempDataMain.push('</table>');

$('body').append(tempDataMain.join(''));

Post a Comment for "Adding Table Header And Footer With Jquery"