Giter VIP home page Giter VIP logo

colreorderwithresize's People

Contributors

anees042 avatar jeffreydwalter avatar jurruh avatar jwalter1-quest avatar martskin avatar recca avatar shashank1010 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

colreorderwithresize's Issues

Resizing column makes the header moves first and then the content

When resizing a column, column header seems to be moving first, then on mouse leave the column content moves.

And also when resizing, some of the columns are being removed from the DOM.

Here is my data table configuration

var table = $('#example').DataTable({
        'ajax': 'https://api.myjson.com/bins/qgcu',
        'dom': 'Rlfrtip',
        'colReorder': {
            'allowReorder': true
        }
});

It works fine as an independent piece of code but causing a problem when I put into my application.

I agree that it could be a problem with my application also, but if anyone can give me some clues about such behavior, it would be helpful for my further investigation.

Fix for wrong columns being selected during state save/restore, inaccurate resizing with scrollY & how to state save widths

Hey there,

I just wanted to share a quick fix I've put in which has made this plugin work much better for me.

Firstly, I was having issues with column indexes changing when this plugin is combined with a state save. This meant that some columns would have incorrect widths applied to them when restored. To remediate this I check for the title attribute to ensure it matches (instead of trusting the index).

Secondly I found that using the jquery .width() sometimes reported back the wrong width. I'm not sure why this happens, perhaps some quirk of jquery. In any case, using the width attribute from the inline style gave me much better results.

To apply these fixes, on line 1263, comment out:

this.s.dt.aoColumns[colResized].sWidth = $(this.s.mouse.resizeElem).width() + "px";

and replace with:

                var thisColTitle = this.s.mouse.resizeElem[0].textContent;
                for (var i = 0; i < this.s.dt.aoColumns.length; i++) {
                    if (this.s.dt.aoColumns[i].sTitle === thisColTitle) {
                        this.s.dt.aoColumns[i].sWidth = this.s.mouse.resizeElem[0].style.width;
                    }
                }

Lastly, whilst I'm here, I figured I may as well share my state saving code as it's alluded to elsewhere but never described. I save the widths as percentages but then restore into px, so that they should be preserved across all screen sizes.

In the datatables options add:

        stateSave: true,
        stateLoadParams: function(settings, data) {
          if (data.columnWidths) {
            data.columnWidths.forEach((item) => {
              const thisColIdx = settings.aoColumns.findIndex(x => x.sTitle === item.key);
              const newWidth = (parseInt(item.value) / 100) * tableWidth; 
              settings.aoColumns[thisColIdx].sWidthOrig = `${newWidth}px`
            });
          }
        },
        stateSaveParams: function(settings, data) {
          // save column widths
          data.columnWidths = [];
          settings.aoColumns.forEach((item) => {
            if (item.sWidth != null) {
              const newWidth = (parseInt(item.sWidth) / tableWidth) * 100; 
              data.columnWidths.push({key: item.sTitle, value: `${newWidth}%`});
            }
          });
        },

Note that this uses ES6 so will need transpiled/polyfilled or modified manually for ES5. The tableWidth is the width of your table.
Hope this helps someone - and thanks a lot Jeffrey for the great plugin!

ColReorderWithResize with responsive:true

I am trying
ColReorderWithResize with responsive:true but I could not resize my columns.

Demo code:

        var table =  $('#demo_datatable').DataTable({
	responsive: true, 
	"dom": '<"custom-table-header"><"custom-table-body"rt><"custom-table-footer"lip>'
	});
	new $.fn.dataTable.ColReorder(table);

Expected output:

Column resize should be work and other column should go under expand section.

Thanks in Advance..

Stacktrace using colReorder with destroy() - fix is in upstream

When using this project with DataTables.destroy(), I get an error like this:

Uncaught TypeError: Cannot read properties of null (reading 'dt')
    at ColReorder._fnStateSave (ColReorderWithResize.js:903:32)
    at ce.fn.init.<anonymous> (ColReorderWithResize.js:773:31)
    at jquery.dataTables.min.js:4:47589
    at Function.map (jquery.min.js:2:3971)
    at R (jquery.dataTables.min.js:4:47536)
    at de (jquery.dataTables.min.js:4:45096)
    at B.<anonymous> (jquery.dataTables.min.js:4:63849)
    at B.iterator (jquery.dataTables.min.js:4:52119)
    at B.<anonymous> (jquery.dataTables.min.js:4:63713)
    at B.visible (jquery.dataTables.min.js:4:53602)

This was also reported upstream and upstream has a fix in this commit. Please apply!

Datatable Column Resizing Issue

Hi, I'm using Datatable with ColReorderWithResize and I'm facing the issue that is when I try to resize one column then it resizes all columns but I want the Left of the columns should be fixed when resizing.

code cleanup

I'd like to clean up this code base because

  1. I'd like to use it
  2. I'd like to modify it and
  3. it will be much easier to use and much easier to modify if we clean it up first

For example:

  • there are 16 unused variables. this creates unnecessary confusion, especially with the similar naming conventions
  • there are various redundant snippets of code that can be consolidated into reusable functions
  • there are a number of implied globals which will raise errors if we put the code through a strict parser

I'd like to fix all of these and submit them back into a pull request.

In addition, I'd like to convert this to typescript and gradually add in the various type checking and other benefits that Typescript offers.

All of the above will be a lot of changes but I'm sure will make this project a lot more valuable to others. Will you accept these changes if I put them all into a pull request? Alternatively, if you prefer, I can just fork this and make the changes there, and we can leave them as separate forked repos.

Unable to resize not sortable columns

Is there any constraint regarding if columns are sortable or not?
I currently have a few datatables (Datatables version 1.1012), where columns with definition "bSortable": false are not resizable as well. If I make them sortable, I can resize the tables.
Thanks

Add package.json so it works with npm

Hello,

could you please include package.json file into the repo, so we can include it in our own package.json files and install it easily using "npm install".

Thanks.

Resize works only with ordering:true

Unable to resize the columns unless I keep ordering option to be true.
I do not wish to give sorting abilities to the user using the datatables because I manage that from the server.
I have reviewed the issue, will try to document it.

In DataTables 1.10.2 https://github.com/DataTables/DataTables/blob/master/media/js/jquery.dataTables.js#L1783
_fnCompatMap( init, 'ordering', 'bSort' ); sets bsort option to be false when i set the ordering option as false.

This results in the column[n].bsortable option to be false as per https://github.com/DataTables/DataTables/blob/master/media/js/jquery.dataTables.js#L2083

With the column[n].bsortable option set to false the plugin cannot set {'cursor': 'col-resize'} on the column, thus disabling the drag and resize functionality of the columns.
https://github.com/jeffreydwalter/ColReorderWithResize/blob/master/ColReorderWithResize.js#L960

Possible fix: checking if (!aoColumns[i].bSortable === false || that.s.dt.oFeatures.bSort === false) on https://github.com/jeffreydwalter/ColReorderWithResize/blob/master/ColReorderWithResize.js#L960
Apologies for the long read.

SCROLL X Breaks the resizing of the columns

Hi,
i have the need to use very large tables, and i need to enable the scrollX=true parameter in datatable.
Unfortunately, the scrollX breaks the resize of the columns (the table body start the new width from 0 px).
resize_bug

ColReorderWithResize not working after chrome update 91.0.447

With "allowReorder": false, and "allowResize": true, I am facing columnWidth resizing issue whenever I try to maximize the column only the header is maximizing horizontally but the below column size are remaining as it is
This was working fine earlier and has caused issues after the latest chrome 91 update.
Attaching the screenshot for reference. Any help in resolving this is appreciated.
Thanks in Advance.

image

Extra Long Words don't wrap

Even when explicitly setting word-break: break-all the cell does not break a long string into multiple lines to adjust for the width resizing.

Cant make column width smaller than content length with white-space:nowrap;

Seems like minimal column width is based on column content, but sometimes it is much reliable not to wrap contenton border but to hide the rest of it. This also let the table to have equal row heights and looks good.

Now if we use white-space:nowrap; over the datatable we can only make widths bigger, but not smaller.

I would be very cool feature i guess, to have fixed minimal width as an option.

resize save current state

The plugin works nicely with datatables 1.10.12, however I can't save the current state after resizing some columns. Do you have any tips how can I achieve saving state?

Thanks

Needs to modify, but isn't modifying, .dataTables_sizing elements

It looks like the code contemplates this but doesn't yet do it-- multiple variables such as $scrollBodyThSizing are set to find the .dataTables_sizing elements, but none of them actually set them, which is a reason (possibly among others, not sure) that this library is not working for me with my Datatables.

Am using the following options:

 {
    dom: 'Rlfrtip',
    data: data,
    deferRender: true,
    scrollCollapse: true,
    scroller: true,
    scrollY: 300,
    ordering: false
  }

Any suggestions?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.