Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compatibility issue in DataTable 2.0.0 #26

Open
tufail-cedcommerce opened this issue Mar 22, 2024 · 4 comments
Open

Compatibility issue in DataTable 2.0.0 #26

tufail-cedcommerce opened this issue Mar 22, 2024 · 4 comments

Comments

@tufail-cedcommerce
Copy link

Hi @dhobi, @jstark518, @jqnatividad, @Javaman1138 and @hchiam, could you please upgrade this plugin so it can work with DataTable 2.0.0 too?

Thank you.

@rahul-katikineni
Copy link

I have been able to make minor modifications for it to work with 2.0
Please have a look and see if it helps.

jquery.dataTables.colResize.txt

@tufail-cedcommerce
Copy link
Author

tufail-cedcommerce commented Mar 28, 2024

I have been able to make minor modifications for it to work with 2.0 Please have a look and see if it helps.

jquery.dataTables.colResize.txt

First of all thanks for the modification.

I've tried using it but it is only resizing the first two rows(this only happens when I don't reduce the number of columns). I need it to resize the complete column. I'm using Server-side processing(AJAX) for populating the data. The table has more than 40 columns. When I reduced the number of columns and tried to fit them into the screen it worked but as soon as we got the horizontal scroll bar(due to a large number of columns) then it stopped working.

I'm using this(scrollX: true) and the table is looking is like this.
image

My table looks like this.
image

Could you please help here @rahul-katikineni.

@mvksages
Copy link

mvksages commented Aug 7, 2024

Do we have any updates on this ? This is very helpful if it works with latest DataTable. Great feature by the way. Worth having it as part of the main github lib.

@fdaugan
Copy link

fdaugan commented Oct 7, 2024

I cannot create a MR based on @rahul-katikineni work because there are too much changes.

However, after few changes changes I got the desired behavior.

Merged file: jquery.dataTables.colResize.js

Changes:

    _fnApplyWidthColumn: function (column, width) {
++    [$(column.nTh.table().context[0].colgroup).find('col')[column.idx], $(column.nTh).closest('table').find('colgroup col')[column.idx]].filter(a => a).forEach(a => a.style = `width:${width}px`);
      $(column.nTh).outerWidth(width + "px");
      column.sWidth = width + "px";
    }

Whith scrollX and orderCellsTop options, extra configuration to avoid trimmed table:

onResize: function (column) {
    const $wrapper = $table.closest('.dt-layout-table');
    const targetWidth = $wrapper.find('.dt-scroll-headInner').width();
    $wrapper.find('table').width(targetWidth).css('max-width', `${targetWidth}px`);
}

Behavior:
Oct-08-2024 00-13-58

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants