Problems using fnUpdate with dataTables 1.9.4
Problems using fnUpdate with dataTables 1.9.4
Hi Alan, please help me xDD
Im using dataTables on my code. I'm trying to update one single row, using this code:
//$('#tableParameters_'+identificadorPerfilado).dataTable().fnUpdate({id:'1', aplicacion:aplicacionAuxM, perfil:codigoPerfilAuxM, idioma:codigoIdiomaAuxM, nombre:nombreLinkP, valor:valor, 8}, numFila);
//$('#tableParameters_'+identificadorPerfilado).dataTable().fnUpdate({'1', aplicacionAuxM, codigoPerfilAuxM, codigoIdiomaAuxM, nombreLinkP, valor, 8}, numFila);
//$('#tableParameters_'+identificadorPerfilado).dataTable().fnUpdate([id:'1', aplicacion:aplicacionAuxM, perfil:codigoPerfilAuxM, idioma:codigoIdiomaAuxM, nombre:nombreLinkP, valor:valor, 8], numFila);
//$('#tableParameters_'+identificadorPerfilado).dataTable().fnUpdate(['1', aplicacionAuxM, codigoPerfilAuxM, codigoIdiomaAuxM, nombreLinkP, valor, 8], numFila);
I have 7 columns on my table, and the last one is the classic column with edit and delete buttons.
numFila is a number, the number of the row y want to update. i figured it out creating a numFila por each row at the fnCreatedRow of the oInit.
I was able to add a row whit this sentence:
$('#tablaParameters_'+identificadorPerfilado).dataTable().fnAddData({id:'1', aplicacion:aplicacionAux, perfil:codigoPerfilAux, idioma:codigoIdiomaAux, nombre:nombreLinkP, valor:valor, data:'8'});
As you can read, 2º and 3º options are not right written, js compleins. So i tried first and last one.
I can not use a regular $('#XXXX') example, because y I have a dynamic number of tables.
So, i dont know if i'm not writting the code right, or if giving the fnUpdate just a number, (numFila) y also wrong.
Thanks so much for any help.
Answers
We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.
Cheers,
Colin
Sorry Colin, i'm not able to link you to an test case. But any help you give me will be very helpful.
I'll try to explain better my problem. I have a table on my .jsp page, and then on js y define it as dataTable.
I have the classic pencil icon, and when y click on it, y star an js function call editParam().
The final situacion is that at the end of that function, y need to update a row of my datatable.
Previously of clicking on the pencil, I use the dataTable funcion of fnCreatedRow (sorry for the spanish name of variables xD):
When i click on my pencil, I show a pop-up window, fill a small form, and click on the save button of my pop-up. I star my save button onClick function, and, after modify my Data base, y need to update visualy the dataTable. Thats the point where I star this function:
function modify(nombreLinkP, valor, identificadorPerfilado, numFila){
}
My table has 7 colums: id, aplicacion, pefil, idioma, nombre, valor, and the icons column. That '8' you see is a random number just to fill that column.
When I use the first line of the code above, I get on console the message: Cant get the 'nTr' propierty ... (something similar, my browser its in spanish.)
When I use the second line, I get a pop-up advise onde browser that sais:
"datatables warning (table id = 'tableParameters_1_DEFAULT_es'): requested unknown parameter 'id' from the datasource for row2"
More information, numFila = nRowString, the variable I got when I created the row.
I think that my problem it's just the way I write the code, something its missing.
I don´t know if that will be usefull, but this line for adding a row to a dataTable its working for me:
$('#tablaParameters_'+identificadorPerfilado).dataTable().fnAddData({id:'1', aplicacion:aplicacionAux, perfil:codigoPerfilAux, idioma:codigoIdiomaAux, nombre:nombreLinkP, valor:valor, data:'8'});
Sorry for such a long post, i'm kinda desperate, imaging my situation, today, in spain is holyday xDD.
Thank for any help
There's a lot going on there, we would really need to see it. If you can't link to your page, please create a test case on http://live.datatables.net/ that replicates the issue, it'll help us to help you,
Colin
Sorry Colin, i'm not able to link you to an test case. But any help you give me will be very helpful.
I'll try to explain better my problem. I have a table on my .jsp page, and then on js y define it as dataTable.
I have the classic pencil icon, and when y click on it, y star an js function call editParam().
The final situacion is that at the end of that function, y need to update a row of my datatable.
Previously of clicking on the pencil, I use the dataTable funcion of fnCreatedRow (sorry for the spanish name of variables xD):
When i click on my pencil, I show a pop-up window, fill a small form, and click on the save button of my pop-up. I star my save button onClick function, and, after modify my Data base, y need to update visualy the dataTable. Thats the point where I star this function:
function modify(nombreLinkP, valor, identificadorPerfilado, numFila){
}
My table has 7 colums: id, aplicacion, pefil, idioma, nombre, valor, and the icons column. That '8' you see is a random number just to fill that column.
When I use the first line of the code above, I get on console the message: Cant get the 'nTr' propierty ... (something similar, my browser its in spanish.)
When I use the second line, I get a pop-up advise onde browser that sais:
"datatables warning (table id = 'tableParameters_1_DEFAULT_es'): requested unknown parameter 'id' from the datasource for row2"
More information, numFila = nRowString, the variable I got when I created the row.
I think that my problem it's just the way I write the code, something its missing.
I don´t know if that will be usefull, but this line for adding a row to a dataTable its working for me:
$('#tablaParameters_'+identificadorPerfilado).dataTable().fnAddData({id:'1', aplicacion:aplicacionAux, perfil:codigoPerfilAux, idioma:codigoIdiomaAux, nombre:nombreLinkP, valor:valor, data:'8'});
Sorry for such a long post, i'm kinda desperate, imaging my situation, today, in spain is holyday xDD.
Thank for any help
As I said, there's a lot going on, so hard to advise without seeing the issue. If you can't link to your page, can you see if you can replicate the issue on http://live.datatables.net/
Colin
Sorry Colin, my third post was a mistake. I give you all the code I have.
JS code
https://gist.github.com/adrianferr/552ee7d9d6caf965be52a82c8fd4ce4f
JSP Code
https://gist.github.com/adrianferr/504db25128aea115becc1b808af8f65d
Well, as i told you before, the problem I have is on js file line 116.
I dont know the exact way to modify a particular row.
Any help will be amazing. Thanks a lot.
I finally got it!!
This code worked for me:
$('#tablaParameters_'+identificadorPerfilado).dataTable().fnUpdate({aplicacion:aplicacionAuxM, perfil:codigoPerfilAuxM, idioma:codigoIdiomaAuxM, nombre:nombreLink, valor:valor}, nTrGlobal);
You can close the post.