How to update attribute element input text id same with autonumber row datatables ?
How to update attribute element input text id same with autonumber row datatables ?

Hello, Please Help Me
I want to update column [PO NO] <input id="cellpono_1">, etc to autonumber like column [NO].
So when I press Enter input element Po No, the table is adding row. The column [NO] is autonumber, If I have 2 row and delete row 1, the [NO] -> 2 is automatic being [NO] -> 1.
What I want to ask? How to update the column [PO NO] <input id="cellpono_2"> to <input id="cellpono_1"> just like column [NO] autonumber ?
Here the link to the page :
http://live.datatables.net/ligoqelu/2/edit
Thank you
This question has an accepted answers - jump to answer
Answers
Hi @Addison ,
I just took a look, and it seems to me that it is incrementing the IDs - I'm seeing
Can you give a step by step instructions on how to reproduce your issue, please.
Cheers,
Colin
Yes, Thank you @colin, For example:
1. If I make two rows with twice enter in input element PO NO. will create NO. 1 - cellpoNo_1 , NO. 2 - cellpoNo_2
2. Then I delete row id NO. 1 - cellpoNo_1
3. Now my row id with NO. 2 - cellpoNo_2 change to NO. 1 - cellpoNo_2
The issue:
I want when I delete NO. 1 - cellpoNo_1 then :
row id with NO. 2 - cellpoNo_2 change to NO. 1 - cellpoNo_1
So number in [NO] and cellpoNo is same after I delete other row.
Hi @Addison ,
You're going to need a bit more logic to do that. Imagine you've got 10 rows, and you delete the first, you'll need to change all of the later rows. To do that, iterate through all the rows with
rows().every()
, and decrement the contents of each withrow().data()
for any row that comes after.Hope that helps,
Cheers,
Colin
Thank you, @colin
I figured the way with rows().every()
The result:
http://live.datatables.net/ligoqelu/4/edit
Well Done