Add a increment for Add and Remove Buttons
Add a increment for Add and Remove Buttons
rdb
Posts: 9Questions: 2Answers: 0
I am looking to Add an incremented number to my Add and Remove buttons. So AddBtn_0 is this possible to do with Data Tables? Here is my Code:
This question has accepted answers - jump to:
This discussion has been closed.
Answers
I'm afraid I don't quite understand. Are you able to mock up a screenshot?
Thanks,
Allan
Similar to how I have this on a button:
<a href="/ArtistAccount/TES0000000001A/SongManagement/TES0000000005S/Recordings" **id="recordingWork_0**">Recordings</a>
Oh I see - you just want to add an id to the button? Use
buttons().nodes()
and loop over the button elements, adding the ids you want.Allan
Hi Allan,
Thanks for the recommendation, do you know how I could do it with my code, as its a little different.
Hi Allan,
Do you know if I could do it using: https://datatables.net/examples/server_side/ids.html
Sounds like you are asking about the buttons you are adding to each row but Allan is talking about buttons added using the Buttons extension.
I'm not sure but I think the syntax you have is incorrect. Maybe this example will help:
http://live.datatables.net/qemodapi/1/edit
Kevin
Hi Kevin,
Right okay. i will have a look at that, I was not sure if there was something that I could already use within DataTables. It works to a points, its just each time the table is re-drawn when it adds or removes the count is not reset.
I'm not sure what counts you are talking about. Maybe you can provide a link to your page or a test case showing the issues.
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin
Hi Kevin,
It's not public facing so I can't show you, I can only show you the code I currently have. In the past, I have added id's to each button using pagination, so that when it loads the data into the data table say you have 50 results it paginates the number of results. but when it loads the table with the add buttons it would have AddBtn and then as the id have _0 for the first record in the table.
Maybe you can update my test case with your code?
Maybe you saw this but if you look at the
columns.render
docs themeta.row
that I use in the example is the row index. Is that what you are looking for?Kevin
Hi Kevin,
There is a JSFiddle in my original question.
Yes there isa fiddle in the first post but it doesn't appear to run and there is a lot of code. I see this in the fiddle:
Is this the button you want to increment the
id
? Can you use thedata["ID']
value for the ID if the row index is not good?Maybe it would help to understand what you are doing with the row
id
. Is it sent to the server and needs to be something specific?Kevin
Hi Kevin,
meta.row
seems to have worked.Thanks