0

I am trying to resize jquery table header columns. I can do it with in a single table but I am unable to do that if header is with fixed table header.

My jsfiddle trials are below:

With Single Table Header:

With Fixed Table Header:

How can I make fixed table header work with a resize pointer at end of th text?

$(function() {
    var pressed;
    var start;
    var startX;
    var startWidth;
    var wrapper = $("div#wrapper");
    var container = $("table#fixedHeaderTable");

    $("table th").mousedown(function(e) {
        start = $(this);
        startX = e.pageX;
        startWidth = $(this).width();
        $(start).addClass("resizing");
        pressed = true;
    });

    $(document).mousemove(function(e) {
        if(pressed) {
            var newWidth = startWidth + (e.pageX - startX);
            start.width(newWidth);
            wrapper.width(container.width() + 10);
        }
    });

    $(document).mouseup(function() {
        if(pressed) {
            $(start).removeClass("resizing");
            pressed = false;
        }
    });
});
0

1 Answer 1

2

There is a little correction to the code you wrote. Please find the fiddle

I added following lines to your code. Hope it helps

contentColumn = $('#contentsTable').find('td').eq($(this).index());

contentColumn.width(newWidth);    
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.