ce icon indicating copy to clipboard operation
ce copied to clipboard

Hide row number column

Open bennyzr opened this issue 7 years ago • 21 comments

Is it possible to hide the row number column on the left of the table?

bennyzr avatar Feb 05 '19 18:02 bennyzr

$('.jexcel_label').hide()

On Tue, Feb 5, 2019 at 6:34 PM bennyzr [email protected] wrote:

Is it possible to hide the row number column on the left of the table?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/paulhodel/jexcel/issues/288, or mute the thread https://github.com/notifications/unsubscribe-auth/AFvagcbtAux9J1qOOXOYgps1nBBnf-89ks5vKc6jgaJpZM4aj0Pz .

pphod avatar Feb 05 '19 21:02 pphod

Interesting, thanks.

However, using this leaves me with an extra column on the left with a width of 30.

bennyzr avatar Feb 05 '19 21:02 bennyzr

Interesting, thanks.

However, using this leaves me with an extra column on the left with a width of 30.

There is a place in jquery.jexcel.js where line no:462,472 where the table header and table content width is defaulted to 30. If you change it to 0 if you do not need the row number to display.

I was successfully able to hide the row number column and use for my requirement.

avidsouza avatar Feb 06 '19 09:02 avidsouza

Your idea does get rid of the left column.  However, the right most column is not accessible. It's a different style and you can't enter anything into the cells. Good, Fast, Cheap; Pick any two.

On Wednesday, February 6, 2019, 4:37:15 AM EST, avidsouza <[email protected]> wrote:  

Interesting, thanks.

However, using this leaves me with an extra column on the left with a width of 30.

There is a place in jquery.jexcel.js where line no:462,472 where the table header and table content width is defaulted to 30. If you change it to 0 if you do not need the row number to display.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

bennyzr avatar Feb 06 '19 18:02 bennyzr

Commenting lines 462, 472, & 1502 in jquery.jexcel.js and classes .jexcel > div > table > thead > tr.jexcel_filter > td:first-child, .jexcel > div > table > tbody > tr > td:first-child in jquery.jexcel.css does the trick

bennyzr avatar Feb 06 '19 22:02 bennyzr

I am going to add a method to do that, should commit that soon.

pphod avatar Feb 06 '19 23:02 pphod

I am going to add a method to do that, should commit that soon.

Hi Paul can you please guide me on Issue reported on #286. Thanks in advance

avidsouza avatar Feb 07 '19 08:02 avidsouza

On V3, showIndex(), hideIndex()

pphod avatar Aug 02 '19 19:08 pphod

Hi,

I just tried using hideIndex() on V3 which removed the column though it kept the index number in the existing left most column. Shouldn't hideIndex() remove the index number as well? Also, any chance of adding this option to the init options?

How about hiding the column headers?

bennyzr avatar Aug 12 '19 21:08 bennyzr

I used the following css to hide row numbers and the last column it leaves behind: .jexcel_selectall { display: none }

.jexcel_row { display: none }

colgroup>col:last-child { width:0; }

lyassa avatar Nov 07 '19 20:11 lyassa

I guess this was resolved some time ago.

pphod avatar Nov 07 '19 20:11 pphod

Oops ... you are right. Thanks Paul for pointing that out. I see now your reply "On V3, showIndex(), hideIndex()".

lyassa avatar Nov 07 '19 21:11 lyassa

Thanks Paul. hideIndex() worked fine

UrmilaShell avatar Nov 18 '19 18:11 UrmilaShell

@paulhodel is there a way to incorporate hideIndex() into the table object? something like this:

    var myTable = jexcel(document.getElementById('spreadsheet'), {
        url: '/gantt_data',
        columns: headers,
        onload: function(a, b) {
            var count = headers.length; 
            for(var i=7;i<=count;i++){
                b.headers[i].classList.add('employee');
            }
        },
        hideIndex:true,      <--------------- this
        columnResize:false,
        nestedHeaders:[
                {
                    title: 'SCHEDULE',
                    colspan: headers.length-2,
                },
        ], 
    });

3AUCE avatar Mar 27 '20 16:03 3AUCE

couldnt work out how to name tabs to variables such as "myTable" to call hideIndex() so added no3 in the below list so its default - currently around line 500 but search for "Content table" as is the comment in the file. Side note on tabs when I empty the "spreadsheet" div ready to load another then it leaves class="jexcel_tabs" (on "spreadsheet" div) which causes the next load to error.. Currently I have to both empty the "spreadsheet" div and remove the class... to have a global var "myTable" clears the loading error if "$(myTable).remove()"; but there are still tab issues as in the tabs (new table) the old tabs get added to.

// Content table obj.table = document.createElement('table'); obj.table.classList.add('jexcel'); obj.table.classList.add('jexcel_hidden_index'); // added this - removes index column as a default obj.table.setAttribute('cellpadding', '0'); obj.table.setAttribute('cellspacing', '0'); obj.table.setAttribute('unselectable', 'yes');

debdansoph avatar Jun 30 '20 19:06 debdansoph

document.getElementById('spreadsheet').jexcel.hideIndex();

pphod avatar Jun 30 '20 19:06 pphod

not working in chrome... had tried that (and many more) using Jquery selector... tried with your vanilla and does not work... it did not work before I discovered tabs and so I learnt to assign the table to a variable (myTable) => when you called it against a non tab table using myTable.hideIndex() it worked... the same does not work for tabs nor does yours or anything else I can find... nice plugin still finding my feet with it but I cant do it without the above as commented EDIT: Put it on a timeout to give the table plenty of time to load - just in case - nope cant get anything to work - my suggestion would be put it as an option as suggested by 3AUCE Also suggests that I am not going to be able to call methods against the tabs but we will see - getting ahead of myself

debdansoph avatar Jun 30 '20 19:06 debdansoph

If you wish to create an example on jsfiddle I am happy to take a look.

pphod avatar Jun 30 '20 21:06 pphod

https://jsfiddle.net/shropford/t6bcg1Ld/16/

Done.. note that if you remove the removeClass("jexcel_tabs") on line 2 then switching from tabs and then back has issues... now my set up may be wrong but it works - so I dont know...

debdansoph avatar Jun 30 '20 22:06 debdansoph

For anyone finding this issue

table.jexcel colgroup col:first-child {
    width: 0 !important;
}

does the trick pretty nicely.

gterras avatar Nov 08 '21 18:11 gterras