Griddle icon indicating copy to clipboard operation
Griddle copied to clipboard

Custom column width and Horizontal Scroll?

Open mr-bobz opened this issue 10 years ago • 17 comments

Does Griddle support custom column width? Would be really nice to be able to specify column width as absolute (px) or relative (%). I believe currently the columns are equally sized as per available width.

Also any chance of getting horizontal scroll for tables with a large no: of columns?

Btw, great work guys, otherwise Griddle is nice, light and quite functional!

mr-bobz avatar Dec 03 '15 03:12 mr-bobz

You can do this by ensuring that you haven't specified "table-layout:fixed" in the CSS for the Griddle table and then use cssClassName in the columnMetadata option to set column widths as you like.

jgwconsulting avatar Dec 03 '15 12:12 jgwconsulting

Hi there and thanks for the kind words. The next version of Griddle has the more "infinite" horizontal scroll as well as vertical.

As far as column width -- the suggestion made by @jgwconsulting is a good solution for now. We're hoping to have more customization options for 1.x.

ryanlanciaux avatar Dec 03 '15 14:12 ryanlanciaux

Awesome, both column width and horizontal scroll works! Thanks @jgwconsulting :+1:

Appreciate the quick response @jgwconsulting and @ryanlanciaux :smiley:

We found some accessibility issues during our testing, I hope we can fix and contribute them?

mr-bobz avatar Dec 03 '15 14:12 mr-bobz

hi, can you please publish a small example of how to control column width with cssClassName? Thank you !

pupsanka avatar Dec 13 '15 08:12 pupsanka

Look at cssClassName property under Column Metadata here: http://griddlegriddle.github.io/Griddle/customization.html

eg:

<Griddle 
     columnMetadata = {[
                { columnName: "label",  displayName: "Name", cssClassName: "LabelColumn"},
                .
                .
               ]}
/>

and in your CSS

.LabelColumn{
    width: 150px;
}   

You can also experiment with max-width too.

mr-bobz avatar Dec 13 '15 14:12 mr-bobz

thank you mr-bobz, it worked. Almost... I am using infiniteScroll and fixedHeader, and with this particular combination the trick does not good - it works only for the titles, and not for the whole table... I saw vidhib reported this bug in https://github.com/GriddleGriddle/griddle-render/issues/18, but i didn't find any more references to this issue.. Any idea if it had been fixed? Even a non-official version will do, Griddle is a lovely table, the best i've seen so far!

pupsanka avatar Dec 14 '15 09:12 pupsanka

Thanks @pupsanka and sorry about the delay in response. Sorry to hear this is not working out so well. We're working on a new version that will hopefully make this sort of operation a lot nicer. The issue you referenced is not yet resolved but should be with 1.0.

ryanlanciaux avatar Jan 02 '16 06:01 ryanlanciaux

Any progress on this? THe problem i'm facing is the table is 100% and inside a grid layout that is auto width base (bootstrap's md-10). So how can you set a fixed with for selected columns when the others are not fixed? Or the table is not fixed?

aaronucsd avatar Mar 04 '16 00:03 aaronucsd

So the table-layout: auto is inline style. Where do we override this to turn it off so it works for using cssClassName?

<table class="" style="width:100%;table-layout: auto;"

aaronucsd avatar Mar 04 '16 00:03 aaronucsd

Seems like the issue was i had useFixedHeader. Took that out and now my cssClassName works

aaronucsd avatar Mar 04 '16 00:03 aaronucsd

It be nice if we can drag and set the width like Microsoft's Excel spreadsheets.

aaronucsd avatar Mar 04 '16 01:03 aaronucsd

@aaronucsd I'm glad you found a workaround for the time being. We do plan on adding the ability to drag column widths as a plugin in 1.0

ryanlanciaux avatar Mar 04 '16 02:03 ryanlanciaux

Sweet! On Mar 3, 2016 6:24 PM, "Ryan Lanciaux" [email protected] wrote:

@aaronucsd https://github.com/aaronucsd I'm glad you found a workaround for the time being. We do plan on adding the ability to drag column widths as a plugin in 1.0 http://griddlegriddle.github.io/Griddle/next/docs/plugins/usingPlugins/

— Reply to this email directly or view it on GitHub https://github.com/GriddleGriddle/Griddle/issues/282#issuecomment-192065631 .

aaronucsd avatar Mar 04 '16 02:03 aaronucsd

Any example for horizontal scroll ?

vyadav12 avatar May 16 '16 08:05 vyadav12

It worked for me

poisonaby avatar Oct 20 '16 11:10 poisonaby

@aaronucsd I wanted to keep the fixed header since we have infinite scroll enabled so I did the unthinkable and mixed jQuery and React. I did something like this to override the inline styling applied to the body <table>

componentDidUpdate: function () {
    $("table:eq(1)").attr("style", "width:100%");
}

Alongside using a custom CSS class for the columns. Super hacky, but hey it works.

Is there a better solution than what I'm doing while keeping the fixed header?

Thanks

nlokare avatar Nov 01 '16 01:11 nlokare

All -- thank you for the discussion here. We've released Griddle 1.0 and have a new customization model that may make interacting with column widths easier. Please take a look at the styles section and customization section from the docs.

Closing this one for now but please feel free to open a new issue if any problems are encountered. :+1:

ryanlanciaux avatar Feb 26 '17 01:02 ryanlanciaux