How change formar a field of datatables?

How change formar a field of datatables?

GeraDuronGeraDuron Posts: 8Questions: 3Answers: 0

var editor;

$(document).ready(function () {
    editor = new $.fn.dataTable.Editor({
        ajax: '@Url.Action("DatosGrid2","Home")',
        table: "#mensajes_editable",
        fields:[

            {
             label: "Usuario",
             name: "usuarios"
         },
         {
             label: "Contraseña",
             name: "contrasena",
             type: "password"
         },
             {
                 label: "Rol",
                 name: "rol"
             }
        ]
    });

  $('#mensajes_editable').DataTable(
        {
            ajax: '@Url.Action("DatosGrid2","Home")',
            dom: "Bfrtip",

            columns:[
                {data:null,render: function(data,type,row){
                    return data.id;
                }
                },
                { data: "usuarios" },
                {data: "contrasena"},
                {data: "rol" },


            ],
        select: true,
        buttons: [
            { extend: "create", editor: editor },
            { extend: "edit", editor: editor },
            { extend: "remove", editor: editor }
        ]
    });

} );

I need show the password field wih a format of ****

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,591Questions: 26Answers: 5,004
    Answer ✓

    For the table you can use something like this to follow the pattern that the editor uses:

                    render: function ( data, type, row ) {
                        if (type === 'display') {
                            return '.'.repeat(data.length);
                        }
                        return data;
    

    Just add the render function to your password column.

    Kevin

This discussion has been closed.