select row by passing a field id
select row by passing a field id
silens
Posts: 101Questions: 40Answers: 0
I would like to be able to select a row with a specific id that I pass
I would like to select a specific row when starting the table
Gracias.
This discussion has been closed.
Answers
Silens, mi amigo. How have you been doing?
Something like this should work:
Hola, gracias por contestar, Estoy recibiendo el siguiente error:
tblRevTarDir.row(...).select is not a function
Gracias amigo
Can you post your code please. Do you have the select extension installed?
Hmmm, I don't see any of the relevant code in there?!
I would add this at the bottom of your function
proyectoFueraPlazo(yourPassedId)
which you need to pass the id to.I use the "init" event here because you said "I would like to select a specific row when starting the table" which I interpreted as meaning "when the table gets initialized".
Por ejemplo, id=0;
Recibo un error:
tblProyectosFueraPlazo.row(...).selected is not a function
Don't know what causes this error but one thing is clear: You won't have a row with an id of 0 in your table ...
I use the same thing and it works fine. So sorry that I cannot resolve this. You would need to post a test case I guess and ask @allan for help. Sorry.
Here is a different way to select a row based on a passed id. Maybe you want to try this: I read the id from a cookie and then loop through all rows of my table and compare the passed id with the id of the row. I think I built this quite a while ago but it still works. Finally I make sure that I am on the right page I guess. That's the draw() at the end:
This may look a bit odd but it also works. I get the selectedId, unselect the record and reselect it 200 milliseconds later. Purely for technical reasons:
Holaa, mi solución:
Parece que fuciona bien. Muchas graciass
Many ways lead to Rome! Glad you got it working!