Quantcast
Channel: Buttons — DataTables forums
Viewing all 479 articles
Browse latest View live

Custome button to url

$
0
0

I've looked everywhere for this, all I want to do is add a button beside the create | edit buttons that will point to a url.
heres what I'm using thus far, the button shows but I'm not getting any URL loading:

        // Display the buttons
    new $.fn.dataTable.Buttons( table, [
        { extend: "create", editor: editor , className: "btn btn-success"},
        { extend: "edit",   editor: editor , className: "btn btn-primary" },

        { sExtends: "text",
          text: "New Record",
fnClick: function ( nButton, oConfig, oFlash ) {

window.location = "http://www.google.co.uk"

}
},

I'm sure there are others who have done this, anyone else know how to do it?

Tom


Copy/CSV/Print buttons with input columns and special characters

$
0
0

Regarding the buttons extension, is there a way, using a formatting function to export the table contents, to export both the content of input elements as well as standard DT cells - with the added monkey wrench that there can sometimes be special characters in some of the cells? Here is a test case of what I am referring to: http://live.datatables.net/leqonovo/2/edit
Currently when clicking the CSV button for example, a js error is thrown, when it encounters a cell with an = for example.

The Save and Cancel Buttons do not appear any more!

$
0
0

I'm codign just as explained in https://editor.datatables.net/reference/api/buttons()

editor
    .title( 'Create new row' )
    .buttons( [
        'Save',
        { label: 'Cancel', fn: function () { this.close(); } }
    ] )
    .create();

But Save and Cancel Buttons do not appear any more.! Where is the conflict???

(function($){
$(document).ready(function() {


    var editor = new $.fn.dataTable.Editor( {
        ajax: 'php/table.contactos.php',
        table: '#contactos',
        fields: [
            {
                "label": "Nombre:",
                "name": "contactos.nombre"
            },
            {
                "label": "Telefono fijo:",
                "name": "contactos.telefono_fijo"
            },
            {
                "label": "Celular:",
                "name": "contactos.telefono_cel"
            },
            {
                "label": "Email:",
                "name": "contactos.email"
            },
            {
                "label": "",
                "name": "contactos.cliente_id",
                "def" : "0000",
                type:   "select"
            },
            {
                "label": "Direccion 1",
                "name": "contactos.dir_fisica_1"
            },
            {
                "label": "Direccion 2",
                "name": "contactos.dir_fisica_2"
            },
            {
                "label": "Direccion 3",
                "name": "contactos.dir_fisica_3"
            }
        ],

//******** Inicia Lenguaje Editar
i18n: {
            create: {
                button: "Nuevo",
                title:  "Crear nuevo registro",
                submit: "Crear"
            },
            edit: {
                button: "Editar",
                title:  "Editar registro",
                submit: "Actualizar"
            },
            remove: {
                button: "Eliminar",
                title:  "Eliminar",
                submit: "Eliminar",
                confirm: {
                    _: "Está seguro de eliminar la linea %d ?",
                    1: "Está seguro de eliminar 1 linea?"
                }
            },
            error: {
                system: "Se ha producido un error, contactar al administrador del sistema"
            },
            datetime: {
                previous: 'Previo',
                next:     'Siguiente',
                months:   [ 'Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio', 'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre' ],
                weekdays: [ 'Dom', 'Lun', 'Mar', 'Mie', 'Jue', 'Vie', 'Sab' ]
            }
        }

//******** Finaliza Lenguaje Editar

    } );


editor
    .dependent( 'contactos.cliente_id', function ( val ) {
        return val === '0' ?
            { show: ['contactos.dir_fisica_1','contactos.dir_fisica_2','contactos.dir_fisica_3'] }:
            { hide: ['contactos.dir_fisica_1','contactos.dir_fisica_2','contactos.dir_fisica_3'] } ;
    } );

// Obtener el Id de la linea seleccionada y guardarla en la variable solId

                var rowId = "99"; // Declarando la Variable
                var solId = rowId;
                var clienteNombre = "Sin Nombre";
                var clienteDirFis1 ="";
                var clienteDirFis2 ="";
                var clienteDirFis3 ="";
                var ubicacionCliente ="";


                // Obteniendo el id de la linea para pasarlo por id
                $('#contactos').on( 'click', 'tr', function () {
                rowId = table.row( this ).id();
                var largo = rowId.length;
                solId = rowId.slice(4,largo);
                console.log(table.row(this).data());
                clienteNombre = table.row(this).data().contactos.nombre;
                console.log(clienteNombre);
                clienteDirFis1 = table.row(this).data().contactos.dir_fisica_1;
                clienteDirFis2 = table.row(this).data().contactos.dir_fisica_2;
                clienteDirFis3 = table.row(this).data().contactos.dir_fisica_3;
                console.log(clienteDirFis1);
                console.log(clienteDirFis2);
                console.log(clienteDirFis3);
                ubicacionCliente = clienteDirFis1 + ' ' + clienteDirFis2 + ' '+ clienteDirFis3;
                console.log(ubicacionCliente);
                } );



    var table = $('#contactos').DataTable( {

        "lengthMenu": [[ 5, 10, -1], [ 5, 10, "Todos"]],
        "order": [[ 1, 'asc' ]],

        dom: 'Blfrtip',
        ajax: 'php/table.contactos.php',
        columns: [
            {
                "data": "contactos.id"
            },
            {
                "data": "contactos.nombre"
            },
            {
                "data": "contactos.telefono_fijo"
            },
            {
                "data": "contactos.telefono_cel"
            },
            {
                "data": "contactos.email"
            },
            {
                "data": "clientes.nombre_comercial"
            },
            {
                "data": "contactos.dir_fisica_1"
            },
            {
                "data": "contactos.dir_fisica_2"
            },
            {
                "data": "contactos.dir_fisica_3"
            }
        ],
        select: true,
        lengthChange: true,
        buttons: [
            { extend: 'create', text: "Nuevo", editor: editor },
            { extend: 'edit', text:"Editar", editor: editor },
            { extend: 'remove', text:"Eliminar", editor: editor },

            {
                extend: "selectedSingle",
                text: "Crear Solicitud",
                action: function ( e, dt, node, config ) {

    var editor = new $.fn.dataTable.Editor( {

        ajax: 'php/table.solicitudes.php',
        table: '#solicitudes',
        fields: [
            {
                "label": "Cliente Nr:",
                "name": "solicitudes.contacto_id",
                "type" : "readonly"
            },
            {
                "label": "Estatus:",
                "name": "solicitudes.estatus",
                "def": "REC",
                "type" : "readonly"
            },

            {
                "label": "Tipo Servicio:",
                "name": "solicitudes.tipo_servicio",
                "type": "select",
                "options": [
                    "Diseño y Construccion",
                    "Acabado y Remodelaciones",
                    "Mtto. Correctivo",
                    "Limpieza",
                    "Mtto. Preventivo",
                    "Facility Management"
                ]
            },
            {
                "label": "Descripcion:",
                "name": "solicitudes.descripcion"
            },
            {
                "label": "¿Urgente?",
                "name": "solicitudes.urgente",
                "type": "radio",
                "def": "No",
                "options": [
                    "Si",
                    "No"
                ]
            },
            {
                "label": "Comentarios:",
                "name": "solicitudes.comentarios_sol"
            },
            {
                "label": "Contacto en sitio:",
                "name": "solicitudes.contacto_sitio"
            },
            {
                "label": "Ubicacion:",
                "name": "solicitudes.ubicacion",
                "type":"textarea"
            },
            {
                "label": "Referencia:",
                "name": "solicitudes.referencia"
            },
            {
                "label": "Condiciones:",
                "name": "solicitudes.condiciones"
            },
            {
                "label": "Fecha Levantamiento:",
                "name": "solicitudes.lev_fecha",
                "type": "datetime",
                "format": "D/MM/YY"
            },
            {
                "label": "Hora Levantamiento",
                "name": "solicitudes.lev_hora"
            },
            {
                "label": "Fecha Cotización",
                "name": "solicitudes.cot_fecha",
                "type": "datetime",
                "format": "D/MM/YY"
            },
            {
                "label": "Notas Cotización:",
                "name": "solicitudes.notas_cot"
            },
            {
                "label": "Comentarios:",
                "name": "solicitudes.comentarios_lev"
            },
                        {
                "label": "Archivo:",
                "name": "solicitudes.archivo",
                type: "upload",
                display: function ( file_id ) {
                    return '<img src="'+table.file( 'files', file_id ).web_path+'"/>';
                },
                clearText: "Clear",
                noImageText: 'No image'
            }

        ],

//******** Inicia Lenguaje Editar
i18n: {
            create: {
                button: "Nuevo",
                title:  "Crear nuevo registro",
                submit: "Crear"
            },
            edit: {
                button: "Editar",
                title:  "Editar registro",
                submit: "Actualizar"
            },
            remove: {
                button: "Eliminar",
                title:  "Eliminar",
                submit: "Eliminar",
                confirm: {
                    _: "Está seguro de eliminar la linea %d ?",
                    1: "Está seguro de eliminar 1 linea?"
                }
            },
            error: {
                system: "Se ha producido un error, contactar al administrador del sistema"
            },
            datetime: {
                previous: 'Previo',
                next:     'Siguiente',
                months:   [ 'Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio', 'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre' ],
                weekdays: [ 'Dom', 'Lun', 'Mar', 'Mie', 'Jue', 'Vie', 'Sab' ]
            }
        }

//******** Finaliza Lenguaje Editar


    } );

editor
    .title( 'Crear Solicitud de: ' + clienteNombre )
    .buttons( [
        'Guardar',
         { label: 'Cancelar', fn: function () { this.close(); } } ] )
    .create()
    .set('solicitudes.contacto_id',solId)
    .set('solicitudes.ubicacion',ubicacionCliente);

                }
            }
        ],

//******** Inicia Lenguaje Display
        language: {

                    "decimal":        "",
                    "emptyTable":     "No hay datos disponibles en la Tabla",
                    "info":           "Mostrando _START_ al _END_ de _TOTAL_ registros",
                    "infoEmpty":      "Mostrando 0 de 0 de 0 registros",
                    "infoFiltered":   "(filtrados de un total de _MAX_ registros)",
                    "infoPostFix":    "",
                    "thousands":      ",",
                    "lengthMenu":     "Mostrar _MENU_ registros",
                    "loadingRecords": "Cargando...",
                    "processing":     "Procesando...",
                    "search":         "Buscar:",
                    "zeroRecords":    "No se encontraron coincidencias",
                    "paginate": {
                        "first":      "Primero",
                        "last":       "Último",
                        "next":       "Siguiente",
                        "previous":   "Anterior"
                    },
                    "aria": {
                        "sortAscending":  ": ordenar columna en orden ascendente",
                        "sortDescending": ": ordenar columna en orden descendente"
                    }
                },
//******** Termina Lenguaje Display

    } );

} );
}(jQuery));

load table with groups of columns hidden; toggle state with colvisGroup button?

$
0
0

I have several columns which are summaries of other detail columns, e.g., col A, which is summary of cols Ax, Ay and col B which is summary of cols Bx, By, Bz.

I'd like the table to be displayed initially with the detail columns not shown, and buttons to show these columns. Once shown, I'd like the button behavior to change to allow the columns to be hidden.

Looking at colvisGroup, it appears the button will either show or hide a set of columns, but not toggle. Am I getting that right? Is there any way to force this to toggle?

  1. Can you recommend the best way to do achieve what I'm trying to achieve?
  2. Additionally, I think I can set the column classname to reference from colvisGroup button with columns.classname. But the docs read that I'm setting the classname of the cells in the column, not the column itself, so I'm not clear on that.
  3. Finally, this would work best if I could place the button in the header of each of the columns which are the summary columns, e.g., with text "+" to expand, and toggles to "-" to contract. Is that possible?

As you may see I'm trying to emulate the excel grouping feature.

Any advice would be very helpful.

Export options

$
0
0

Hi. I have complex structure inside TD. Is it possible to provide some option to exclude some elements from export?
F.ex:
<td data-field="name">
<span class="name">Some Name</span><span class="value hidden">hidden data</span>
</td>

will produce in Excel text: Some Namehidden data
I need to exclude from exort elements with "hidden" class.

Buttons Disappear after adding ajax:"..." data source

$
0
0

Buttons Show when i use html data.

$(document).ready(function() {
 var table = $('#example').DataTable( {
        lengthChange: false,
        buttons: true
    } );

    table.buttons().container()
        .insertBefore( '#example_filter' );
});

</script>

but when i want to use ajax data source, the buttons disappear.

$(document).ready(function() {
 var table = $('#example').DataTable( {
        lengthChange: false,
        buttons: true,
        ajax: "setData.php",
           columns: [...............]

    } );

    table.buttons().container()
        .insertBefore( '#example_filter' );
});



Excel Export doesn't work

$
0
0

neither Flash nor Html5 excel download works in my project (trying in Chrome or FF && ubuntu/windows)

Problem:
the flash excel button appears but downloads empty file
the html5 excel button doesn't throw error but doesnt appear

Facts:
all other buttons get displayed/working
using actual version of Datatable (even nightly html5)
html5 buttons in examples work

Setup:

elem.DataTable({
"aaData":ray,
"aoColumns": col,
"destroy": true,
"dom": 'Bfrtip',
"sScrollX": param.tableScroll,
"buttons":[
'copyHtml5', 'excelHtml5'
],
"order": [[ order.row, order.dir.toLowerCase() ]],
"columnDefs": [{
"render": function(data, type, row){
if(type == "display"){
return moment(data).format("L");
}
else{
return data;
}
}
,"targets": hasDate
}]
});

Dependencys: (in this order (require.js))
'datatables.net',
"datatables.net-bootstrap",
'datatables.net-buttons',
"datatables.net-jszip",
"datatables.net-pdfmake",
"datatables.net-vhf_Fonts",
'datatables.net-buttons-bootstrap',
'datatables.net-buttons-html5',
"datatables.net-buttons-flash",
'datatables.net-buttons-print

i've no idea what could be the problem
i would appreciate every try

Thanks for reading

http://debug.datatables.net/omaged

selectAll not disabled when al rows are selected


CSV Behavior in Safari

$
0
0

Using this page as an example...

In Chrome, the CSV option will download the file just fine. However, in Safari the CSV opens in a new tab. It seems that in order to save the file you have to do the following:

  1. From the menu, go to File > Save As...
  2. Change the export name to have .csv extension
  3. Select "Page Source" as the Format
  4. Click Save

Is it possible to have the file download automatically or is this a limitation with Safari?

Thanks!

-Kurt

Visibility-Toggle only for selected columns?

Hiding columns in ColVis extention for Buttons not working, what did I do wrong?

$
0
0

I have the following definition for my first five columns(there are many more than that):

 "columns": [
            {
                "data": "HasOwnerHistory"
                , "orderable": false
                , "visible": false
                , "className": 'notToggleVis'
            },
            {
                "data": "HasServiceHistory"
                , "orderable": false
                , "visible": false
            },
            {
                "data": "InForService"
                , "orderable": false
                , "visible": false
            },
            {
                "data": "Project"
            },
            {
                "data": "IsPartOfConfig"
                , "orderable": false
            },

The columns display/don't correctly.
I have the following in the DataTable to display ColVis

        , buttons:
            [
             {
                "extend": 'colvis'
                 , "columns": ':not(.notToggleVis)'
             }
            ] //end buttons

The ColVis button shows up correctly. However, no matter what I try for the columns, I can not get a single column to disappear from the list.

I've tried (columns: ':not(:first-child)') from the following discussion:
https://datatables.net/forums/discussion/35949
Didn't work.

My goal is to remove the first four columns from the ColVis list. I would have thought this would be easy but obviously, I've missed something. The first three columns are used to generate another column and are "meaningless" for the end user.

Export to XLSX with customized styles

$
0
0

DataTables has some 67 built-in styles for customizing cells in an exported XLSX document.
Is there a way to edit or add to these built-in styles, or to create a customized style that gets added to the stylesheet?

For example, when I export a table and add cells at the bottom to for Subtotal, GST (goods and services tax) and Total, I'd like the amounts in bold and formatted as currency. Using the built-in styles, I can apply bold or currency formatting, but not both.

Also, if I use built-in style 57 (dollar currency values), the '$' appears after the amount (rather than before). When I checked the number formatting in Excel, it appears that the built-in style's currency format uses "$ Cherokee (Cherokee)". I'd like it change it (or add a new style) so that it uses "$ English (Canada)".

Jake (Canada)

button pdf, print

$
0
0

I have in the Datatables instead of Male and Female an Icon and if they is a member of a listed group a check icon instead of 1.
if I want to export the table via print pdf the columns are empty. Is it possible to render the field to the icons if someone click on the Buttons? The icons are fontawesome and render into the table.

custom Button

$
0
0

One feature in my Project should be, that the User select a row and send the data, over a defined modal windows (in there to set the e-Mail Address,.. ) to one or more Athlete. The Modal windows are already loaded in the html. Is it possible to click on a Button, that open the modal windows and insert the selected row?
I read the extension select and Buttons. I have no idea, how can I do this. The select events example shows a example to get the Data, but how can I open the modal windows and put the Data in the Windows. In the Button Section I did not find any Information about that

Andreas

Button Collection and bootstrap

$
0
0

I am a little helpless. I have a button group inserted as in your export buttons example. The export button is displayed correctly, but the dropdown field does not look the same as in the example. Only the name is displayed and the corresponding icon. The button design is totally missing. I have added the class btn and btn-default. Now I have a frame, but the distances do not fit and all buttons are displayed in a row. The comparison with your example and the one on my site shows a big difference. The buttons in the example are designed with div and in my Page with ul tag. Normally I should be able to adjust everything with css, but here I do not know where to start. I tried something, but then the table looks strange. The design did not fit at all.
You can see it via the link I sent you.

Andreas


How to set the active state when a button is clicked in the "column groups" example?

$
0
0

I would like to set the active state when a button is clicked in the Column Groups example, and unset the active state for the other buttons. I have created a JSFiddle with my attempt to solve the problem. Unfortunately my code seems to toggle all the buttons, instead of only the one I click. If one button is clicked twice, the active state is deselected when it should remain selected.

Thanks

Excel export unusable for tables with large datasets?

$
0
0

I use the excel export option in a project for tables that can have a lot of data (near 10,000 rows). Datatables performs well, but after I upgraded to Datatables Editor 1.6, when I try to use the Excel export option, the process takes forever. For a table with 1,300ish rows, it takes almost two minutes to export now whereas before it would only take a second or two (see attached screenshot).

I ran a couple of profiles tests on it, and I narrowed down the problem to a regular expression in the function _addToZip. Here is the line:

str = str.replace( /<(.*?) xmlns=""(.*?)>/g, '<$1 $2>' );

Two questions:

  1. I changed the line to be as follows and the execution time went down to one second as it used to be. Could this work as a substitute line? (I am not at all familiar with the XLSX spec).:
str = str.replace(' xmlns="" ', '');
  1. Is this line really necessary (i.e. are the Excel files broken if it's not there)? I look in the previous version of DTE and it wasn't there and our excel files worked fine at the time.

Thanks for all your help and your time!

Page count in footer when exporting DataTable table with pdfmake

Link in 'message' of pdfHtml5 button

$
0
0

I would like to place a link in the text of 'message' within a pdfHtml5 button.

            {
                extend:    'pdfHtml5',
                text:      'PDF',
                titleAttr: 'PDF',
                title: 'My title',
                header: true,
                message: 'And I would like to have a link <a href="www.google.com">here</a>. Many thanks. ',
                customize: function(doc) {
                    doc.defaultStyle.fontSize = 6;
                                        doc.styles.title.margin = [0, 20, 0, 12];
                }
            }

I suppose I need a function for 'message'?! ... but how do I do this? https://datatables.net/reference/button/pdfHtml5

And trying to set the titles margin with doc.styles.title.margin = [0, 20, 0, 12]; does not trigger? Why so?

Excel Column width

$
0
0

I tried searching for this but all I am finding references TableTools... is there anyway to make the export function for Excel using Buttons to set the column width? I would really like for it to just autowidth.

Viewing all 479 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>