drvic10k / bootstrap-sortable

adding sorting ability to bootstrap table
MIT License
513 stars 131 forks source link

New feature to your excellent script #85

Closed zloystrelok closed 8 years ago

zloystrelok commented 8 years ago

Hello! Thank you very much for your excellent script. It's really easy to use and quite powerful.

Would you please add one tiny feature to it? I'm talking about optional first column with Line No., 1,2,3, etc. which will be constant in any sorting type.

drvic10k commented 8 years ago

hi, currently you cannot set indices, but you can fix position of some rows by putting attribute data-disable-sorting on them. such rows won't be sorted then

does that cover your use case?

zloystrelok commented 8 years ago

Hello! I want to have first column with 1,2,3 no matter what sorting is applied to the table. It's not about fixing position of rows.

drvic10k commented 8 years ago

so you mean that before sorting the rows are not first, second thirs, but after sorting, you want to have them in that order?

zloystrelok commented 8 years ago

i mean that i want to count rows visually, and I need first column with line nos. Want a screenshot?

drvic10k commented 8 years ago

yes please, I think I don't understand what you mean

zloystrelok commented 8 years ago

image

drvic10k commented 8 years ago

aha, so you want the column to be fixed, that's unfortunately not possible, because the sorting is done on rows as the smallest entity

there is an event triggered after the sorting, so you can hook on it and change the content of the first column after sorting

zloystrelok commented 8 years ago

Yes, exactly. I know that now there's no such functionality :) What about implementing it in new version? :)

drvic10k commented 8 years ago

I'm affraid that it's not possible with how the sorting works

zloystrelok commented 8 years ago

Well', I'm done with this script:

$('#statTable').on('sorted', function () {
                var userListTable = document.getElementById('statTable');
                for (var i = 1; i < userListTable.rows.length; i++) {
                    userListTable.rows[i].cells[0].innerText = i;
                }
            });
drvic10k commented 8 years ago

yes, that's what I meant