problema mrender datatables asp.net

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.

preguntado el 21 de septiembre de 13 a las 00:09

1 Respuestas

Figured it out. There was a lot wrong.

  1. mDataProp is need for the rendered column.
  2. row is not an array.
  3. there was an unecessary " after the forward slash
  4. 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 or haz tu propia pregunta.