-
-
Notifications
You must be signed in to change notification settings - Fork 47k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added a column in Table to show serial number(e.g from 1 to ...100), when other columns sorted, keep the serial number column unchanged(still from 1 to ...100) #8311
Comments
It's easy to implemented on the user side. I don't think it should be a build in feature. const columns = [{
title: 'Id',
key: 'index',
render = (text, record, index) => index,
}] |
Sorry, I can't solve this. Could you give me some advices to help me ? thank you ! @yesmeck |
See my comment above. |
Thank you very much! I understood the API better! And I think your comment above should be colon after render function instead of equal sign!@yesmeck |
but when i move to the second page the number is not continous |
it does not work with pagination, the index will alway starts from 0 even if you are at page 2 |
@yesmeck this issue should be reopend since your solution does not solve it properly |
how about if you manually provide the numbering from data retrieval |
how about this render: (text, record) =>{array.indexOf(record) + 1} |
@touatoua @muhaimincs it does not work if you use the sorting of the table, as the order of the data internally used by Table is not the same as the data you hold in your code. |
Final Solution: This is how you will use it;
Then inside your columns variable, you call the closure like this
Please note here that the reason for the conditional statement checking if the current page is 1 (pagination.current () ) is because the fromCurrentIndexNumber can be called more than once when the page loads initially, and we don't want our first row to start from 9 or 10 depending on the number of times it was initially called. the pagination test prevents it from incrementing unnecessarily. |
|
tasks.indexOf(task) + 1; |
|
{ where : |
Great !!!! Thank you so much. It helped me <3 |
this works |
I used method customRender on {
title: "#",
dataIndex: "id",
key: "id",
customRender: ({ index }) => {
return current.value === 1 ? index + 1 : (current.value - 1) * pageSize.value + (index + 1);
},
}, |
What problem does this feature solve?
add a cloumn in Table to show unchangeable serial number
Added a column to show serial number(e.g from 1 to ...100), when other columns sorted, keep the serial number column unchanged(still from 1 to ...100)
What does the proposed API look like?
Column API sort={false|true}
The text was updated successfully, but these errors were encountered: