problema mrender datatables asp.net
Frecuentes
Visto 458 veces
0
I'm trying to create a link in every cell in the first column but I'm having a bit of trouble. When I use the following code I'm able to see data in the first six columns as expected.
"aoColumnDefs":
[
{"mDataProp": "Title","aTargets": [0]},
{ "mDataProp": "Body", "aTargets": [1], },
{ "mDataProp": "Feelings", "aTargets": [2] },
{ "mDataProp": "Tags", "aTargets": [3] },
{"mDataProp": "Published","aTargets": [4]},
{ "mDataProp": "LastRevised", "aTargets": [5] },
{
"mDataProp": "Id",
"bVisible": false,
"aTargets": [6]
},
However, when I try to create links in the title column based on this example: http://datatables.net/release-datatables/examples/advanced_init/column_render.html
Esto es lo que se me ocurrió:
"aoColumnDefs":
[
{"mRender": function (data, type, row) {
return '<a href="@Url.Action("Details", "Table")/"' + row[6]+'">'+data+'</a>';
},
"aTargets": [0]
},
{ "mDataProp": "Body", "aTargets": [1], },
{ "mDataProp": "Feelings", "aTargets": [2] },
{ "mDataProp": "Tags", "aTargets": [3] },
{
"mDataProp": "Published",
"aTargets": [4]
},
{ "mDataProp": "LastRevised", "aTargets": [5] },
{
"mDataProp": "Id",
"bVisible": false,
"aTargets": [6]
},
I want to display the contents that were previously in the title column again with a link to the details view for each item but the above isn't working.
1 Respuestas
0
Figured it out. There was a lot wrong.
- mDataProp is need for the rendered column.
- row is not an array.
- there was an unecessary " after the forward slash
- mrender is supported beginning in version 1.9.4.
Here is the correct column definition for the "Title" (first) column:
{
"mDataProp": "Title",
"mRender": function (data, type, row) {
return '<a href="@Url.Action("Details", "Table")/' + row.Id+'">'+data+'</a>';},
"aTargets": [0]
},
Respondido el 23 de Septiembre de 13 a las 18:09
No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas asp.net jquery-datatables or haz tu propia pregunta.