-
Notifications
You must be signed in to change notification settings - Fork 325
Column resizing #6
Comments
+1 |
jQuery handsontable Seem to be able to do this quite semantically with |
I was able to use DragTable, a jQuery plug-in that progressively enhances a table to support interactive mouse column reordering. I stored the column order in The way the plug-in works is by overlaying the original table with a [UL] and re-rendering the columns (for a specified number of rows) then attaching jQuery-UI sortable to it. This approach probably wouldn't work for a dual-table where the header row is lined up with the body in separate tables, to enable a fixed header. But the visual effect of seeing the column contents while dragging is compelling. |
I used colResizable to make the columns resizable. Trivial to integrate - works fine with backgrid : ) |
+1 |
@tailless is right. Add colResizeable to the grid after it is initialized, and you are all set. It is being neglected by the author, so make sure you use a forked version of it that has minor bug fixes or converts it to coffeescript. You can even monkey patch it to accept an array of column width percentages for the initial column sizes. |
Can you explain what you mean by "Add colResizeable to the grid after it is initialized"? Perhaps show a code snippet? Thanks! |
He probably means until it's in the DOM. I've found many jQuery plugins won't work unless the target element(s) are in the DOM. For instance Chosen has this problem and doesn't work very comfortably with Backbone. You should be able to render a Backbone view without appending it to the DOM. |
Yes, that is right. Append it to the DOM first before applying the plugin. |
Thanks guys, I just didn't realize that colResizable was a jquery plugin. Everything works great now! |
+1 |
12 similar comments
+1 |
+1 |
+1 |
+1 |
+1 |
+1 |
+1 |
+1 |
+1 |
+1 |
+1 |
+1 |
Any news on this one? |
Not yet. I've been a bit busy and my current contracts aren't paying me to work on it. Sent from my iPhone
|
@WRidder is working it I think. Sent from my iPhone
|
That's correct, will give an update as soon as I have an initial version/proposal. |
I have created two seperate extensions to adress both (re)sizeable columns and (re)orderable columns. See:
These are proposals which I'd like to discuss with anyone interested. These proposals do not yet contain full documentation and tests. The overall intent is to make them fit with backgrid in a manner which requires only minor changes to core backgrid and can easily be enabled/disabled. Sizeable columnsArchitectureIt creates an Currently I've chosen to support a width, max width and a minimum width. These properties can currently be set in the column definition. It sets a Usage// Add sizeable columns
var sizeAbleCol = new Backgrid.Extension.sizeAbleColumns({
collection: pageableTerritories,
columns: columns
});
$backgridContainer.find('thead').before(sizeAbleCol.render().el); Discussion
Resizeable columnsArchitectureOn rendering it will try to find all relevant header It has a dependency on Currently I've chosen to support a width, max width and a minimum width. These properties can currently be set in the column definition. Usage// Add sizeable columns
var sizeAbleCol = new Backgrid.Extension.sizeAbleColumns({
collection: pageableTerritories,
columns: columns
});
$backgridContainer.find('thead').before(sizeAbleCol.render().el);
// Add resize handlers
var sizeHandler = new Backgrid.Extension.sizeAbleColumnsHandlers({
sizeAbleColumns: sizeAbleCol,
grid: pageableGrid,
saveModelWidth: true
});
$backgridContainer.find('thead').before(sizeHandler.render().el);
// Listen to resize events
columns.on('resize', function(columnModel, newWidth, oldWidth) {
console.log('Resize event on column; name, model, new and old width: ', columnModel.get("name"), columnModel, newWidth, oldWidth);
}); Discussion
Reorderable columnsArchitectureOn rendering it will try to find all relevant header As an optimization it does not force the grid to re-render when the order has been changed; it will find all relevant cells and reorder them. It has a dependency on Usage// Make columns reorderable
var orderHandler = new Backgrid.Extension.OrderableColumns({
grid: pageableGrid,
sizeAbleColumns: sizeAbleCol
});
$backgridContainer.find('thead').before(orderHandler.render().el); I'd love to hear anyone's input on these extensions. |
A small update:
Demo: http://techwuppet.com/backgrid_poc_demo/ |
I tried to use sizeable-columns & grouped-columns and I ended up with below error! Any idea where I am doing wrong? Uncaught RangeError: cannot determine header elements for every column. backgrid-sizeable-columns.js:263 -> I had 0 items first time, and I am showing {No Data} message in td with colspan same as total number of columns! Thanks |
It seems working now.. Thanks a lot! |
Alrighty, can you elaborate on the situation which caused the error and how you fixed it? Also keep in mind that these extensions are still a work in progress. If you would like to participate in the discussion regarding this functionality, see: #501 |
@excentris @wyuenho will this get merged in? |
No description provided.
The text was updated successfully, but these errors were encountered: