ce icon indicating copy to clipboard operation
ce copied to clipboard

is there a way to rotate the header text?

Open 3AUCE opened this issue 6 years ago • 9 comments

perhaps i just overlooked it but i cant seem to figure out how to rotate the text within the headers.

something like this:

var headers = [
            {
                type: 'text',
                title:'Name',
                width:120, 
                orientation: vertical //<----- or something like this
            },
];

3AUCE avatar Feb 19 '20 14:02 3AUCE

jEXCEL is just an HTML table, so you can try using CSS. There is no native method for that.

There are a few initial references you can find a solution: https://stackoverflow.com/questions/33913304/how-can-i-rotate-text-inside-table-td-not-on-table-th/33913896

pphod avatar Feb 19 '20 19:02 pphod

@paulhodel any chance you could point me in the right direction for assigning classes to specific column headers/divs?

3AUCE avatar Feb 19 '20 20:02 3AUCE

.jexcel > thead > tr > td

pphod avatar Feb 19 '20 20:02 pphod

@paulhodel thanks for the help. is it possible to assign classes to specific headers? in a perfect world, i would need to rotate specific header cells and not all of them.

3AUCE avatar Feb 27 '20 20:02 3AUCE

I would suggest something like that. https://tympanus.net/codrops/css_reference/nth-child/

pphod avatar Feb 27 '20 22:02 pphod

@paulhodel thanks again on the surface it looks like this solution will not work. its specific to individual, odd, or even numbers. i have two tables. the first table contains the total hours for each employee, the second table allows the user to enter specific hours for each employee for specific tasks. when i implement the nth-child, both tables are affected, also, the employee names within the headers are generated based off of the user input (which means the number of headers and the names within them will change). so being confined to specifying a specific value is not going to work (unless i auto generate each one individually. which is unreasonable). ill keep playing around with it to see if i cant figure something out. let me know if you have any other thoughts. it might be less effort to edit the js to allow for the addition of specific classes to each header element when there created. like this

var headers = [
            {
                type: 'text',
                title:'Name',
                width:120, 
                class: customclass //<----- something like this
            },
];

3AUCE avatar Feb 27 '20 22:02 3AUCE

You can add custom classes by adding that to your initialization:

onload: function(a, b) {
    var col = 0; // First column
    b.headers[col].classList.add('yourCustomClass');
}

pphod avatar Feb 27 '20 22:02 pphod

Have you ever consider jExcel Pro? v5 is coming soon with a lot of new features. https://jexcel.net/v4

pphod avatar Feb 27 '20 22:02 pphod

@paulhodel im working on a proof of concept at the moment. once i get it up and running and im able to get user buy-in, ill be able to get justification/approval for a budget which can be used to upgrade to pro. however, for the time being im limited to the current version. do you have a working example of the onload:function(a,b) ? this seems to be exactly what im looking for.

3AUCE avatar Feb 28 '20 12:02 3AUCE