Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all 82603 articles
Browse latest View live

Maximum column width for all columns

$
0
0

How can I set a maximum width for all columns?
The table is generated dynamically, I can´t tell with column has too much content. Currently, a column with many characters takes up so much space that the table has to be scrolled in x-direction. If the max width is exceeded, there should be a line break.
I tried, with no visible effect:

var columnDefs = [
    {
        width: '50px',
        targets: '_all'
    }
];

Unable to cast object of type 'System.Int32' to type 'System.Nullable`1[System.Int64]'. SearchPanes

$
0
0

This is reference questions :https://datatables.net/forums/discussion/76041

This is looks like bug when I am enabling the ViewTotal=true then datatables.net **server-side code **throw the below error . I am using Datatables-Editor-Server library version 2.2.2 (.Net)

Unable to cast object of type 'System.Int32' to type 'System.Nullable`1[System.Int64]'.

buttons: [
    {
        extend: 'searchPanes',  

        config: {
            cascadePanes: true,
            delayInit: false,
            viewTotal: true,
            //i18n: {                      
            //    count: '{total}',
            //    countFiltered: '{shown} ({total})'
            //},
            layout: 'columns-3',
                preSelect: [
                    {
                        column: 7,
                        rows: [(new Date().getFullYear()-1).toString()]
                    }
                ],
        }
    },
]

responsive server-side works only on first page

Responsive via column merging

$
0
0

I'm working with DataTables and want to achieve a specific behavior when the screen size changes. Instead of just hiding columns on smaller screens and displaying the information as a child row, I want to merge certain columns and have the flexibility to set the resolution where this merging starts.

Here's my desired outcome:

Is it possible to achieve this using DataTables?
Additionally, can DataTables adapt dynamically if the screen is resized?

Row Grouping success but missing styles

$
0
0

I successfully Implemented the rowGroup by using this code
https://datatables.net/forums/discussion/71503/excel-export-with-rowgroup

https://live.datatables.net/hemelesi/42/edit

it works weel, i see the totals generated at my bottom where i added some custom code to do some calulations, the only issue i am having is that i am unable to add some styles to the row data at the bottom, where i am doing some calculations.

Here is the code i have and trying to fix it

where i am trying to make the column, bold, align to the right and have a boder at the top and bottom in black and bacjground as grey:

This is my getTableRow Function

function getTableData(groupName, title, button, dt) {
    var dataSrc = getRow(dt);    
    var header = getHeaderNames(dt);
    var rowNum = 1;
    var mergeCells = [];
    var mergeCol = ((header.length - 1) + 10).toString(36).toUpperCase();
    var ws = '';


    var selectorModifier = {};

    if (button.exportOptions.hasOwnProperty('modifier') ) {
      selectorModifier = button.exportOptions.modifier;
    }

    ws += buildCols(header);
    ws += '<sheetData>';

    // Print button.title
    if (button.title.length > 0) {
      if (button.title === '*') {
        button.title = document.getElementsByTagName("title")[0].innerHTML;
      }
      ws += buildRow([button.title], rowNum, 51);      
      mergeCells.push('<mergeCell ref="A' +rowNum + ':' + mergeCol + '' +rowNum + '"/>');
      rowNum++;             
    }


    // Print button.messageTop
    if (button.messageTop.length > 0 && button.messageTop.length != '*') {
      ws += buildRow([button.messageTop], rowNum, 51);       
      mergeCells.push('<mergeCell ref="A' +rowNum + ':' + mergeCol + '' +rowNum + '"/>');
      rowNum++;
    }

    // All rows on one page with group names separating groups
    if ( Array.isArray( groupName ) ) {
      if (button.header) {
        ws += buildRow(header, rowNum, 2);
        rowNum++;
      }
      var currentGroup = '';
      // Loop through each row to append to sheet.    
      thisTable.rows(selectorModifier).every( function ( rowIdx, tableLoop, rowLoop ) {
        var _data = this.data().slice(0, header.length);
        var data = transformData(_data);

        if (data[dataSrc] !== currentGroup ) {
          currentGroup = data[dataSrc];
          ws += buildRow([currentGroup], rowNum, 51);
          mergeCells.push('<mergeCell ref="A' +rowNum + ':' + mergeCol + '' +rowNum + '"/>');
          rowNum++;
        }          
        // If data is object based then it needs to be converted 
        // to an array before sending to buildRow()
        ws += buildRow(data, rowNum, '');
        rowNum++;
      } );

    } else {
      // Place each group on individual sheets
        if ( title ) {
          ws += buildRow([title], rowNum, 51);  
          mergeCells.push('<mergeCell ref="A' +rowNum + ':' + mergeCol + '' +rowNum + '"/>');
          rowNum++;
        }          
      if (button.header) {
        ws += buildRow(header, rowNum, 2);
        rowNum++;
      }
      // Loop through each row to append to sheet.    
      thisTable.rows(
        function ( idx, data, node ) {
            let displayText = data[dataSrc].display;
                const match = displayText.match(/<a[^>]*>(.*?)<\/a>/);
                if (match && match[1]) {
                  displayText = match[1].trim();
                } else {
                  displayText = displayText.trim();
                }
                    if(displayText == '-') {
                        displayText = 'No Group';
                    }
          return displayText === groupName ?
            true : false;
        },
        selectorModifier
      ).every( function ( rowIdx, tableLoop, rowLoop ) {
        var _data = this.data().slice(0, header.length);
        var data = transformData(_data);
        // If data is object based then it needs to be converted 
        // to an array before sending to buildRow()
        ws += buildRow(data, rowNum, '');

        rowNum++;
      });

    }

    // Calculate totals for specific columns before the footer
    const totalColumns = [14, 15, 18, 19, 20, 21, 22];
    const totals = calculateColumnTotals(dt, totalColumns, groupName);

    // Build the totals row
    let totalsRow = Array(header.length).fill(''); // Fill all cells with empty string
    totalsRow[0] = groupName + ' :'; // Set the group name in the first cell
    totalColumns.forEach((colIndex, index) => {
        totalsRow[colIndex] = totals[index].toFixed(2); // Place totals in specified columns
    });

    ws += buildRow(totalsRow, rowNum, '');
    mergeCells.push('<mergeCell ref="A' + rowNum + ':N' + rowNum + '"/>'); // Merge first 14 columns
    rowNum++;


    // Output footer
    if (button.footer) {
      ws += buildRow(getFooterNames(dt), rowNum, 2);
      rowNum++;
    }

    // Print button.messageBottom
    if (button.messageBottom.length > 0 && button.messageBottom.length != '*') {

      ws += buildRow([button.messageBottom], rowNum, 51);

      mergeCells.push('<mergeCell ref="A' +rowNum + ':' + mergeCol + '' +rowNum + '"/>');
      rowNum++;
    }

    mergeCellsElement = '';

    if (mergeCells) {
      mergeCellsElement = '<mergeCells count="' + mergeCells.length + '">'+
        mergeCells +
       '</mergeCells>';
    }
    ws += '</sheetData>' + mergeCellsElement;

    return ws;

  }

function calculateColumnTotals(dt, columns, groupName) {
    let totals = new Array(columns.length).fill(0);
    dt.rows({ search: 'applied' }).every(function() {
        var data = this.data();
        var _currentGroup = data[getRow(dt)]; // Ensure this is fetching the correct group
        var currentGroup = extractPlainText(_currentGroup);
        if(currentGroup == '-') {
            currentGroup = 'No Group'
        }
        if (currentGroup === groupName) {
            columns.forEach((colIndex, i) => {
                let cleanValue = data[colIndex].toString().replace(/[^\d.-]/g, '');
                let value = parseFloat(cleanValue);
                if (!isNaN(value)) {
                    totals[i] += value;
                }
            });
        }
    });
    return totals;
    }


function transformData(dataArray) {
        return dataArray.map(item => {
            // Initialize an object to hold the transformed data
            let transformedItem = {};

            if (typeof item === 'object' && item !== null) {
                // If it's an object, use the 'display' property directly
                transformedItem = item.display || ""; // Use an empty string if 'display' is not available
            } else if (typeof item === 'string') {
                transformedItem = stripHtmlJS(item);
            } else {
                // For any other types (e.g., null, undefined), use an empty string
                transformedItem = "";
            }

            return transformedItem;
        });
    }

Cannot create property 'searchBuilder' on string

$
0
0

Error messages shown:

dataTables.searchBuilder.mjs:3388 Uncaught TypeError: Cannot create property 'searchBuilder' on string 

Description of problem:
This happens on the front end side when I set ajax.data to JSON.stringify(data) with contentType:"application/json" in order to enable serverSide processing. It seems like this is an error in the search builder package when creating searchBuilder attribute to the data while the data is being string:

this.s.dt.on('preXhr.dtsb', function (e, settings, data) {
                if (_this.s.dt.page.info().serverSide) {
                    data.searchBuilder = _this._collapseArray(_this.getDetails(true));
                }
            });

However, according to ajax document, data should be stringified so that the server can decode it. I don't know what I'm missing here.

Thank you very much for the support! Let me know if you need any other information.

Best,
Ha

which web development agency excels in both creativity and functionality?

$
0
0

Can anyone recommend a web development agency that not only crafts visually stunning designs but also ensures seamless functionality?

I’m Looking for a partner that goes beyond the basics, perhaps one that adds a touch of innovation to every project.

Dom => Layout conversion

$
0
0

How to convert this DataTables 1.x configuration:

$.extend($.fn.dataTable.defaults, {
dom: '<"datatable-scroll-wrap"t><"datatable-footer"ip>'
});

to new layout option available in DataTable 2.x

I have a problem how to define css class names in layout structure.


datatable + laravel + livewire

$
0
0

Hi
In my project I use livewire with datatable and modal. When I show modal:
public function show($regeneration)
{

$this->dispatch('open-modal', 'detailsModal');
}

all add-ons such as search engine, sorting and paging disappear.

When I close modal still all adds are unavilable

I tried :
$('#tabela').DataTable().ajax.reload();
but still nothing

Why?
How to reload datatable?
BR

Issues with DataTables Not Refreshing After Update or Insert

$
0
0

Link to test case: no link
Debugger code (debug.datatables.net): no error
Error messages shown: no message
Description of problem:

Hello everyone,

I'm experiencing an issue with DataTables on my web page. I have two DataTables, and while one refreshes correctly after an update, the other does not. Here is a brief overview of my setup:

I am using DataTables with Editor for inline editing.
Each table has its own AJAX configuration, Editor instance, and event handlers.
Both tables are set up similarly, but only one of them refreshes automatically after an update.
Here is the relevant part of my PHP code:

<?php

/*
 * Editor server script for DB table vehicle
 * Created by http://editor.datatables.net/generator
 */

// DataTables PHP library and database connection
include( "lib/DataTables.php" );

// Alias Editor classes so they are easy to use
use
    DataTables\Editor,
    DataTables\Editor\Field,
    DataTables\Editor\Format,
    DataTables\Editor\Mjoin,
    DataTables\Editor\Options,
    DataTables\Editor\Upload,
    DataTables\Editor\Validate,
    DataTables\Editor\ValidateOptions;

$id = isset($_POST['id']) ? intval($_POST['id']) : 0;

// Build our Editor instance and process the data coming from _POST
Editor::inst( $db, 'mileage' )
    ->where('mileage.vehicle_id', $id)
    ->field(
        Field::inst( 'mileage.id' ), //->set( false ),
        Field::inst( 'mileage.vehicle_id' ),
        Field::inst( 'mileage.mileage' )
            ->validator( Validate::numeric() ),
        Field::inst( 'mileage.dt_mileage' )
            ->validator( Validate::dateFormat( 'm/d/y' ) )
            ->getFormatter( Format::dateSqlToFormat( 'm/d/y' ) )
            ->setFormatter( Format::dateFormatToSql( 'm/d/y' ) ),
        Field::inst( 'mileage.action_by_id' )
            ->options( Options::inst()
                ->table( 'users' )
                ->value( 'id' )
                ->label( array('name', 'last_name') )
            ),
        Field::inst( 'users.name' )
            ->set( false ),
        Field::inst( 'users.last_name' )
            ->set( false )
    )
    ->leftJoin( 'users', 'users.id', '=', 'mileage.action_by_id' )
    ->debug(true)
    ->process( $_POST )
    ->json();

Here is the relevant part of my JavaScript code:

        var editorMileage = new DataTable.Editor( {
            ajax: 'php/table.vehicle_mileage.php',
            table: '#vehicle_mileage',
            fields: [
                { label: "Mileage:", name: "mileage.mileage" },
                { label: "Date:", name: "mileage.dt_mileage", type: "datetime", "format": "MM\/DD\/YY" },
                { label: "Action By:", name: "mileage.action_by_id", type: "select" },
                { label: "Vehicle ID:", name: "mileage.vehicle_id", type: "hidden" }
                /*{ label: "First Name:", name: "users.name", type: "readonly" },
                { label: "Last Name:", name: "users.last_name", type: "readonly" },
                { label: "Vehicle ID:", name: "mileage.vehicle_id", type: "readonly", def: vehicleId }*/
            ]
        });
        /*editorMileage.on('postCreate postEdit', function(e, json, data) {
            table.ajax.reload(null, false); // Reload the table data, keeping the current paging
        });*/
        //DEBUG
        editorMileage.on('submitComplete', function(e, json, data) {
            console.log('Table1 submit complete', json, data);
            //tableMileage.ajax.reload();
        });
        // Ajout du preSubmit pour définir vehicle_id lors de la création
        editorMileage.on('preSubmit', function (e, data, action) {
            $.each(data.data, function (key, values) {
                data.data[key]['type'] = 'mileage';
            });
            if (action === 'create') {
                data.data[0].mileage.vehicle_id = vehicleId;
            }
        });
        
        var tableMileage = new DataTable('#vehicle_mileage', {
            ajax: {
                url: 'php/table.vehicle_mileage.php', // URL de votre script PHP
                type: 'POST',
                data: function(d) {
                    d.id = vehicleId; // Ajoute l'ID dans les données POST
                },
                dataSrc: 'data'
            },
            columns: [
                { data: 'mileage.mileage', title: 'Mileage' },
                { data: 'mileage.dt_mileage', title: 'Date' },
                {
                    data: null,
                    render: function (data, type, row) {
                        // Combine the first and last names into a single table field
                        return data.users.name + ' ' + data.users.last_name;
                    }
                }
                //{ data: 'users.name', title: 'First Name' },
                //{ data: 'users.last_name', title: 'Last Name' }
            ],
            colReorder: true,
            layout: {
                topStart: {
                    buttons: [
                        { extend: 'create', editor: editorMileage },
                        { extend: 'edit', editor: editorMileage },
                        { extend: 'remove', editor: editorMileage },
                        {
                            extend: 'collection',
                            text: 'Export',
                            buttons: ['copy', 'excel', 'csv', 'pdf', 'print']
                        }
                    ]
                }
            },
            responsive: true,
            select: true
        });

Could someone help me identify potential reasons why tableMileage might not be refreshing automatically? Any guidance or suggestions would be greatly appreciated.

Thank you!

Edited by Allan - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

Header checbox for select all don't work with select2

$
0
0

Hello can you help me please ?

I use select2 with datatable

return new DataTable(`#${tableName}`, {
            scrollX: true,
            responsive:true,
            destroy: true,
            autoWidth: true,
            serverSide: serverSide,
            searching: false,
            processing: true,
            language: dataTablesFr,
            ajax: dataToPost,
            columnDefs: columnDefinition,
            paging: true,
            dom: 't<"bottom"<"data-table-pagination-footer"ilp>',
            select: {
                style: 'os',
                selector: 'td:first-child',
                headerCheckbox: true
            }
        });

            const dataTable =  DataTableEditorSetting.create(
                        tableName,
                        dataToAjax,
                        [
                            {
                                orderable: false,
                                render: DataTables.render.select(),
                                targets: 0
                            },

and i have a <th></th> my datatatble work well but no checkbox header to select all

<th data-dt-column="0" rowspan="1" colspan="1" class="dt-orderable-none dt-ordering-asc" aria-sort="ascending" aria-label=""><span class="dt-column-title"></span><span class="dt-column-order"></span></th>

I dont find why, have you idea please ?

tabindex handling in WCAG aware areas

$
0
0

Link to test case: none
Debugger code (debug.datatables.net): none
Error messages shown: none
Description of problem:

With version 2.0.5 (and 2.0.8 by only looking at the code) and a Bootstrap 4 UI, the tabindex="0" is emitted even on elements that are already focusable. E.g. for <a> elements this attribute is redundant. Our particular problem area is the "paging area".

Current HTML code:

<li class="dt-paging-button page-item">
<a href="#" class="page-link" aria-controls="faqsupfedgov" 
  data-dt-idx="1" tabindex="0">2</a></li>

Expected HTML code:

<li class="dt-paging-button page-item">
<a href="#" class="page-link" aria-controls="faqsupfedgov"
 data-dt-idx="1">2</a></li>

Thanks for your help in advance :)

is there a chance to have / implement child rows with Javascript (array / objects)?

$
0
0

hi datatable enthusiasts,

i would love to implement the child row feature BUT my data are coming in with a javascript array ( data: customerData)...
all the examples are on ajax... i did spent already some extensive time to try to get it to work, but guess what: no success!
hm, my app foundation is wordpress, which may make it a little bit more complex, than a pure html / javascript environment.

any chance for it? instead of hidding columns and use the row click feature to bring up a modal window to show the rest (details) of the full record.

any tipp, hint, advise would be very much appreciated.
cheers
tomek

show only filter record data another filter like excel

$
0
0

Hello
This is my html page

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>demo</title>


<link rel="stylesheet" type="text/css" href=dt.css />
<link rel="stylesheet" type="text/css" href=select.css />

 <script type="text/javascript" src="select.js"></script>
  <script type="text/javascript" src="button.js"></script>
   <script type="text/javascript" src="buttona.js"></script>
    <script type="text/javascript" src="buttonab.js"></script>



<script type="text/javascript">
    $(document).ready(function () {
        var thArray = [];
        $('#list > thead > tr > th').each(function () {
            thArray.push($(this).text())
        })
        var rowCount = $('table#list tbody tr').length;
        sessionStorage.setItem("rowCount", rowCount);
        // Remove the formatting to get integer data for summation
        var intVal = function (i) {
            return typeof i === 'string' ?
                i.replace(/[\$,]/g, '') * 1 :
                typeof i === 'number' ?
                    i : 0;
        };
         $('#list').DataTable({
            "ordering": false,
            dom: 'Bfrtip',
            "buttons": [{
                extend: 'excel',
                footer: true,
               // title: "Test",
                title: "CHEMICAL ARRIVAL - ISSUE DETIALS",
                className:'btn-success',
                exportOptions: {
                   // columns: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],
                    format: {
                        header: function (data, index, column) {
                            return thArray[index]
                        }
                    }
                }
            }
            ],

lengthMenu: [
        [2000, 1500, 1000, 500, -1],
        [2000, 1500, 1000, 500, 'All'],
    ],

            initComplete: function () {
                this.api().columns([1, 2, 3]).every(function () {
                    var title = this.header();
                    //replace spaces with dashes
                    title = $(title).html().replace(/[\W]/g, '-');
                    var column = this;
                    var select = $('<select id="' + title + '" class="select2" ></select>')
                        .appendTo($(column.header()).empty())
                        .on('change', function () {
                            //Get the "text" property from each selected data 
                            //regex escape the value and store in array
                            var data = $.map($(this).select2('data'), function (value, key) {
                                return value.text ? '^' + $.fn.dataTable.util.escapeRegex(value.text) + '$' : null;
                            });
                            //if no data selected use ""
                            if (data.length === 0) {
                                data = [""];
                            }
                            //join array into string with regex or (|)
                            var val = data.join('|');
                            //search for the option(s) selected
                            column
                                .search(val ? val : '', true, false)
                                .draw();
                        });
                    column.data().unique().sort().each(function (d, j) {
                        select.append('<option value="' + d + '">' + d + '</option>');
                    });
                    //use column title as selector and placeholder
                    $('#' + title).select2({
                        multiple: true,
                        closeOnSelect: false,
                        width: '100%',
                        placeholder: "" + title
                    });
                    //initially clear select otherwise first option is selected
                    $('.select2').val(null).trigger('change');
                });
            },
            footerCallback: function (tfoot, data, start, end, display) {
                let api = this.api();
                api.column(2).footer().innerHTML = "GRAND TOTAL";
                // Total over all pages
                total = api
                    .column(3, { search: 'applied' })
                    .data()
                    .reduce((a, b) => intVal(a) + intVal(b), 0);




                // Update footer
               api.column(3).footer().innerHTML = total.toFixed(0);


            }
        });
    });
</script>

<style>

.btn-success {
        width: 110px;
        height: 40px;
        background-image: url('images/excelnew.png');
        background-repeat: no-repeat;
        background-size: cover;
        position: relative;
        left:682px; 
        top: -34px;
        display: block;
        text-indent: -9999em;
    }

    .select2-results__options[aria-multiselectable="true"] li {
        padding-left: 30px;
        position: relative;           
    }
        .select2-results__options[aria-multiselectable="true"] li:before {
            position: absolute;
            left: 8px;
            opacity: .6;
            top: 6px;
            font-family: "FontAwesome";
            content: "\f0c8";
        }
        .select2-results__options[aria-multiselectable="true"] li[aria-selected="true"]:before {
            content: "\f14a";
        }

        table {
 margin: 0 auto;
 margin-top: 20px;
 width: 100%;
 position: relative;
 overflow: auto;

}
th, thead {
position: sticky;
top: 0;
border: 1px solid #dddddd;
background-color: #ABEBC6;
text-align: center;
table-layout: fixed;

 height: 25px;

}
</style>

</head>
<body>
<form id="form1" runat="server">
<div>
<div id="c1" runat="server">
<table cellspacing="0" class="myClass" id="list" style="width: 1400px; font-family: Calibri; font-size: 11px; border-collapse: collapse; border: 1px solid black; z-index: 102;">
<thead>
<tr>

              <th style="width:60px;text-align:center;">F1</th>
                <th style="width:110px;text-align:center;">F2</th>
                <th style="width:150px;text-align:center;">F3</th> 
                <th style="width:40px;text-align:center;">F4</th>



            </tr>
        </thead>
        <tbody style="border-collapse: collapse; border: 1px solid black;">

<tr>
<td>APPLE</td>
<td>G1</td>
<td>K1</td>
<td>11</td>
</tr>

<tr>
<td>MANGO</td>
<td>G3</td>
<td>Q2</td>
<td>10</td>
</tr>

<tr>
<td>BANANA</td>
<td>V1</td>
<td>G4</td>
<td>40</td>
</tr>

<tr>
<td>Kiwi</td>
<td>R4</td>
<td>G4</td>
<td>30</td>
</tr>

<tr>
<td>Papaya</td>
<td>E3</td>
<td>W4</td>
<td>10</td>
</tr>

<tr>
<td>Watermelon</td>
<td>S1</td>
<td>Q1</td>
<td>4</td>
</tr>

        </tbody>
        <tfoot>
            <tr>

         <td style="background: sandybrown; border: 1px solid black;"></td> 

         <td style="background: sandybrown; border: 1px solid black;"></td>

         <td style="text-align:right;border-collapse: collapse; background: sandybrown; border: 1px solid black; font-size: larger; font-weight: bold;font-size:20px;"></td>

         <td style="text-align:right;border-collapse: collapse; background: sandybrown; border: 1px solid black; font-size: larger; font-weight: bold;font-size:20px;"></td> 





           </tr>
        </tfoot>
    </table>
</div>
</div>
</form>

</body>
</html>

I have 4 cloumn F1,F2,F3,F4 I have applied multi filter for F2,F3,F4 all working fine only one problem for example i filter in f2 G1,R4 it has to show In F3 Filter data K1,G4 And In F4 Filter data 11,30 but its shwoing in F3 and F4 all data in filter how to solve this in my above code

Because each row of my table input has sub items, similar to the table below, is there any example?

$
0
0

Because each row of my table input has sub items, similar to the table below, is there any example related to this that I can refer to?

Link to test case:

Debugger code (debug.datatables.net):

Error messages shown:
Description of problem:


Double " l "button

$
0
0

Help please

here is my dom below

"<'row'" +
"   <'col-sm-12'" +
"       tr" +
"   >" +
">" +
"<'row px-4 py-2'" +
"   <'col-12 col-md-7 mb-2 mb-md-0 d-flex flex-wrap align-items-center justify-content-start'" +
"       li" +
"   >" +
"   <'col-12 col-md-5 d-flex align-items-center justify-content-end'" +
"       p" +
"   >" +
">",

The 'l dt length' button is duplicated, as shown in the picture

How can I export two rows in the tfoot of my table to Excel?

$
0
0

Good morning, I have a table with two rows in the tfoot section. When I export it to Excel, it only shows one row. Is there a way to export both rows from the tfoot? I hope you can help. Thank you.

datatables 2 ajax change dilemma

$
0
0

datatables 2 changes the way how ajax server side processing works: It will fetch the data from ajax call during datatables initilization. This has performance concerns like unneccessary server and database access if we want to encourage users to enter filters before loading the data(but not force them to enter filters).
I have tried different ways:
Use empty url for datatables initialization; use data:function(d){xxx} to send dynamic parameters and set the url using ajax.Url('xxx').load() api or first set url('xxx') and the use ajax.reload().
Nothing work because the dynammic parameters are not passed in after setting the new url.
This works fine in datatables 1.x because we don't need to change the url and it won't automatically call the ajax function during initialization.
In datatables 2, only if we don't change the url then the dynamic parameters will be passed in. But then we are facing the performance hit which I am trying to avoid.
In a dilemma now and hope there is a solution. Thanks.

How do I convert this table into searchable, sortable datatable?

Search Builder "searchable=false" behavior seems wrong to me

$
0
0

I have a datatables instance which uses both the standard search box which searches all columns (lets call it "Quick Search") and searchBuilder.

I have three columns that conflict with each other when using quick search. One is a department name, the next is a department hierarchy from the university level down to the department so it includes the department name and the third is a specific level within the hierarchy which represents a "school" which could also be the department for a given row. This results in "Quick Search" not working if you allow all three columns to be searchable. So I have disabled search for the hierarchy and the school with searchable=false but I allow the search to work across the department column with searchable=true.

Now that I have added searchBuilder I was happy to see the two "non-searchable" columns were still listed in the Search Builder list of columns. However when I base a search on one of these columns no data is returned. If I change the column to searchable and test again then searchBuilder works. So I think search builder is inconstantly honoring the searchable boolean. It either should not include the column in the list of columns you may base your search on or it should include the column in the list and should work as you would expect if that column is searched.

I prefer the later because "Quick Search" needs these two columns to be disabled since it is very basic and looks for data across all columns at the same time, but searchBuilder which addresses each column independently doesn't need to have search disabled and honestly I can't think of a case where you would want to disable a column in searchBuilder.

If anyone thinks it is necessary to be able to disable search on a column in searchBuilder then I think there needs to be two "searchable" booleans. One for the standard search and another for searchBuilder. Perhaps searchBuilderSearchable=false or something like that.

Viewing all 82603 articles
Browse latest View live


Latest Images

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