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

Add a row inline


Highlight an entry in row if contains pattern

0
0

Hi,
New to DataTables so please pardon if a re-post.
Is it possible to highlight an entry (either bold or different color) in a row if it contains a pattern? Eg.,
Make the 3rd entry bold if it contains a 'G'.
T/G G/G **A/G** NA A/A NA

To take it further, is it possible to make only 'G' appear in bold (and not 'A')?
T/G G/G A/**G** NA A/A NA
Thanks so much!

Need to remove bold font from search box.

0
0

In the jquery datatable i have search box, i wanted to remove bold font from search box, by default its taking bold font. Please help me on that

Scrolling by row

0
0

I'm aware of being able to scroll to a specific row, but not really sure what event I can attach to for scrolling (both via the scrollbar and arrows + page up/down buttons).

Is it possible to control scrolling such that it will "snap" to whole rows?

datatable css rendering out of table

0
0

For chrome browser the css shading goes outside the table. This is from recent updates to google chrome. Anybody have a fix?

Change inline value before display

0
0

Hi

Firstly, thanks for answering all my recent questions!

My scenario is as follows.

My database stores money in pennies (so £100 = 10000).

When the data comes through to datatables I have set a render function to convert them to pounds and pennies - which is working fine.

The issue is that when the inline editor is opened it shows the original data.

I tried putting an event listener on preOpen but it is not helping:

    transactionEditor.on('preOpen', function (e, mode, action) {
      
      if (mode == "inline") {
        var modifier = transactionEditor.modifier();
  
        if (modifier) {
          currentRow = stTable.row(modifier.row).data(); 
          currentRow.AllocCurrencyAllocatedAmount /= 100;
        }
     }
    });

Do you have suggestions?

I really appreciate your help.

Thanks

Dov

Update running totals in column on filter event

0
0

I have a column in a table that calculates a running total in a table:

"render": function ( data, type, row, meta ) {
if (meta.row == 0) {
requestedRunningTotal = Number(row[meta.col - 1]);
} else {
requestedRunningTotal = requestedRunningTotal + Number(row[meta.col - 1]);
}

return requestedRunningTotal;

}

It works fine but does not recompute if the table is filtered (values being filtered are in another column). Is there a way to cause the column or cells to recompute using the displayed filtered rows, i.e., show the running total of the filtered values?

Bootstrap Datepicker questions

0
0

I have 2 datepickers in 'el' format and when i select a date,they filter a datatable (data[4], date with time) as follows:

      $.fn.dataTable.ext.search.push(
      function (settings, data, dataIndex) {
      var min = $('#apo').datepicker("getDate");
      var max = $('#ews').datepicker("getDate");
      var startDate = new Date(data[4]);
      if (min == null && max == null) { return true; }
      if (min == null && startDate <= max) { return true;}
      if (max == null && startDate >= min) {return true;}
      if (startDate <= max && startDate >= min) { return true; }
      return false;
       });

When the page loads,the 2 datepicker have NULL values and the datatable shows all records.

When i select a date from the datepickers,the filters work ok but the dates i get (with console.log) are like this:

        Date 2018-10-31T22:00:00.000Z 

and in console it appears many many times, around 100 times.Why?

I would like the date from the 2nd datepicker to add +1 day to the selected date, so that i can filter in the right way,because if i choose the same day in both datepickers it returns 0 records.How can i achieve that?

Finally,the time i get from Datepicker is UTC time.Here,we are +02:00 ,how can i make it show the right time and not UTC?Should i use moment.js?

Thank you.


Using Responsive >=2.x & ColVis - Show Hidden Columns In Child Row?

0
0

I found the following question and relative answer on Stack Overflow: https://stackoverflow.com/a/32993719/2110294

Which points to a previous discussion on these forums: https://datatables.net/forums/discussion/29860/using-colvis-button-with-responsive-table-disables-hidden-columns

In this we find the following example: http://live.datatables.net/poqoyezo/1/edit

In this example, when a column is hidden / shown by ColVis it is added or removed from the child row.

Bumping the dependencies to the latest versions shows that this functionality is no longer the same.

Reverting the Responsive dependency to 1.0.7 shows that it something that changed between this version and version 2 which created these changes.

Is it possible that we can recreate this behavior with version >=2.0.0 of Responsive, could anyone share an updated example of this?

Many thanks.

EDIT: Here is a test case: http://live.datatables.net/femudeda/1/edit

Datatables break with multiple datatables within tabs

0
0

I have an issue were I get the following error:

TypeError: this.api.cell(...).index(...) is undefined; can't access its "column" property

What I wanted to ultimately accomplish is to have a datatable per tab on a page and have the databales be responsive to mobile viewports. But it's only responsive for the first tab and breaks on the second tab.

As mention above the code breaks on the next tab and specifically on the second row of the datatable within the next tab.

I have over simplified my code here, without removing the main components.

I'm building this page based on a template and the javascript code use to manipulate the datatables comes from that template. Like I said it works for the first tab and crashes on the second row of the datatable in the next tab.

I'm no expert in javascript however I'm currently trying to debug the issue myself. But if I can have this issue resolve by the experts here then I would greatly appreciate that as I don't have much time and wasn't expecting to have this error. I have search the internet and this forum for any situation similar to mine but didn't find anything the closest thing I have found is an issue with the columns needing resizing when a tab is shown.

My actual page has six tabs and I noticed from some testing that its always the next tab. Currently in the pastebin code I have referrenced above their is a datatable code for each tab its always the second javascript code that crashes hence I said the next tab. So it issue goes as follow:

javascript code for Tab1 and Tab2 = Tab1 working Tab2 row2 crashes
javascript code for Tab2 and Tab3 = Tab2 working Tab3 row2 crashes
javascript code for Tab3 and Tab4 = Tab3 working Tab4 row2 crashes
javascript code for Tab4 and Tab5 = Tab4 working Tab5 row2 crashes
and ...so on

Just mention this incase it helps with debugging.

If anymore information is need please let me know.

Thanks,
Jerg

Isssue in Serverside Scroller?

0
0

Hi @allan ,

In my application we implemented Scroller for that we are using (serverside: true) event to getting the data from the backend.
when we scroll down the Ajax call hit POST method and the data coming but I am using inline editable also, so in my application I created a PUT method in backend ,so when we update the field the Ajax call went to POST method. But my expected result is it need to went PUT method.
I need suggestion while updating any field need to stop POST call and to invoke the PUT call. For this I didn't create any test case , but I referred data table example .so in that example also while updating the field the call goes to POST call only.

Url: https://editor.datatables.net/examples/inline-editing/serverSide.html

This is the example we are referring
Please suggest on this

Thanks
Saidulu

Fixed header Alignment issue.

0
0

Like many others I have an issue with the fixed header not aligning properly as I start to scroll.

The code pen I have created doesn't have the problem. see here

However, my development site which uses the same code does. see here

I have tried using a small data set as well on the dev site but the results are the same.

I have seen the columns.adjust().draw() but am not 100% sure where to place this.

Responsible table and click

0
0

hi

I have an datable who is responsive

var specificationsTable = $('#specificationsTable').DataTable({
    "language": {
        "url": url
    },
    'dom': 'tp',
    responsive: {
        details: {
            display: $.fn.dataTable.Responsive.display.childRowImmediate,
            type: ''
        }
    },
    "bLengthChange": false, //hide 'show entries dropdown
    "paging": false,
    "searching": false,
    "info": false
});

I have this click event

$("#specificationsTable tbody").on('click', 'td', function(e) {

    var tr = $(this).closest('tr');

    //in case row is displaye on many row... (responsive)
    if ( $(tr).hasClass('child') ) {
        tr = $(tr).prev();  
    }


    //delete button
    if(specificationsTable.cell(this).index().column == specificationsTable.columns()[0].length-1){
       ...
    }

});

That work when all column are displayed on the same row... but otherwise, this line
specificationsTable.cell(this).index().column

is not working, I get

Cannot read property 'column' of undefined

thanks

Elipsis on my button

0
0

hello could anyone solved or at least let me know where is my fault?

im using AdminLTE Version 2.4.0
with bootstrap 3.3.7 installed
and a datatables.

Datatables won't work on my real data

0
0

When I used dummy data, the program run smoothly, but when I used my real data which consist of 500 thousand rows it won't work. Is there any limitation in datatables that I should know of?


Autocomplete with flexdatalist, id input search, init function

0
0

Hi,

I have a problem with DataTables,
I would like to add an autocomplete with the search box, my first problem is I can't assign an ID to the search input outside of the ".datatable" (I can, but always in the 'initComplete').

My second is when I assign an ID, then I add flexdatalist and refresh the "function" of "flexdatalist", it's fonctional but when I click in the search input my cursor/focus is off, and I must re-click to can type letters but it's always focus off (the search works but not the autocomplete and my letters disapear), the both (DataTables and flexdatalist) don't work correctly together ahaha
Also everytime I click on, my page returns to the top,

Maybe a solution ?

PS : flexdatalist works when I specify the code : <input id="ac-0083" class="flexdatalist">
outside of the datatables

Thanks

` $.extend( $.fn.dataTable.defaults, {

    "dom": '<"top"AfB>rt<"bottom"ip><"clear">',

    "language": {
        "url": "//cdn.datatables.net/plug-ins/1.10.16/i18n/French.json",
        "decimal": ",",
        "thousands": ".",
        "language": {
            alphabetSearch: {
                alphabet: '#ABCDEFGHIJKLMNOPQRSTUVWXYZ',
                infoDisplay: 'Afficher :',
                infoAll: 'Tous'
            }
        }
    },

    "paging": true,
    "pagingType": "full_numbers",

    "ordering": true,

    "searching": true,

    "info": false,

    "pageLength": 25,

    fixedHeader: {
        header: true,
        footer: true
    },

     buttons: [
        {
            text: 'Réinitialiser',
            action: function ( e, dt, node, config ) {
                dt.search( '' ).draw();
            }
        }
    ],

   initComplete: function () { //WORK

        var idTable = this.attr('id'),
            idDataList = $("#" + idTable ).attr('data-id-ac');
            initDataList = $("#" + idTable ).attr('data-init');

        if ( idDataList != 0 && initDataList != 1 )
        {
            $("#" + idTable + "_filter input").attr('id', idDataList ).addClass('flexdatalist');
            $("#" + idTable ).attr('data-init','1');
            initialiseDatalist();
        }

    } */


} );

$('.table-liste').DataTable( {
} );

/* $("#table-liste-0083_filter input").attr('id', 'ac-0083' ).addClass('flexdatalist');
initialiseDatalist(); */ //DOESN'T WORK

$('#table-liste-0083').DataTable( {

    "pageLength": 35,

    "order": [[0, 'asc']],

    rowGroup: {
        dataSrc: 1
    },

    "dom": '<"top"Bf>rt<"bottom"ip><"clear">',

    alphabetSearch: {
        column: 1
    },

    "columnDefs": [
        {
            "type": 'natural',
            "targets": [ 0 ],
            "visible": false, 
            "searchable": false,
            "orderable": false
        },
        {
            "targets": [ 1 ],
            "visible": false, 
            "searchable": true,
            "orderable": false
        },
        {
            "targets": [ 2, 3 ],
            "visible": true, 
            "searchable": true,
            "orderable": false
        },
        {
            "targets": [ 4, 5, 6, 7 ],
            "visible": true, 
            "searchable": false,
            "orderable": false
        }
    ]

} );

function initialiseDatalist(){

var idDataList = $('.flexdatalist').attr('id');
$('.flexdatalist').attr('list', idDataList + '-datalist')

$('.flexdatalist').flexdatalist({
    minLength: 2,
    searchByWord: true,
    searchContain: false,
    maxShownResults: 5,
    noResultsText: 'Aucun résultat pour "{keyword}"',
    normalizeString: function (string) {
        return latinize(string);
    }
});

}

initialiseDatalist();`

<table id="table-liste-0083" data-id-ac="ac-0083" class="display" width="100%">

Ajax Cant render Vue component!

0
0

I'm trying to connect Datatable in Ajax mode and Vue component, which should, if successful, render the Order button of the Product. I created an API for my web application, and through the get-query I pass the JSON to the AJAX table property. All data is displayed correctly, and even one button is an order, but it is not a Vue component, but a simple HTML.
So I pass to JSON this string
<order :product=2 :ordered=true></order>
but as a result, this row is written to the table cell, it is not converted into a vue-component...

if I pass this line in normal datatable mode (without Ajax) - the component is rendered, there are no problems.

My json looks like

My ajax Datatable looks like

My normal (no-ajax) Datatable looks like

The Datatable JavaScript Code

    var table = $('#table1').DataTable({
            "ajax": '/api/v1/products',
            responsive: true,
                "dom": '<"top"flp<"clear">>rt<"bottom"ifp<"clear">>',
                "columns": [
                    { "width": "5%" },
                    { "width": "20%" },
                    null,
                    null,
                    null,
                    null,
                    { "width": "10%" },
                    null,
                    null,
                    null
                ]
                });
                setInterval(function() {
                table.ajax.reload();
                }, 3000 );

Anyone can help me? I need to render the Vue button on Ajax Datatable mode...
In no-ajax mode - all ok..

how to display chid of chid data

0
0

here we use row click on row we display child row . than how to display child of child in datatable. that menad i wnat click on full name it also display child row row how to implement this

why datatables not working after i move it into different server?

0
0

the previous server datatables works just fine but the new server does not. already move the datatables folder but still
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!-- Meta, title, CSS, favicons, etc. -->
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">

<!-- Bootstrap -->
<link href="../vendors/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
<!-- Font Awesome -->
<link href="../vendors/font-awesome/css/font-awesome.min.css" rel="stylesheet">
<!-- NProgress -->
<link href="../vendors/nprogress/nprogress.css" rel="stylesheet">
<!-- iCheck -->
<link href="../vendors/iCheck/skins/flat/green.css" rel="stylesheet">
<!-- Datatables -->
<link href="../vendors/datatables.net-bs/css/dataTables.bootstrap.min.css" rel="stylesheet">
<link href="../vendors/datatables.net-buttons-bs/css/buttons.bootstrap.min.css" rel="stylesheet">
<link href="../vendors/datatables.net-fixedheader-bs/css/fixedHeader.bootstrap.min.css" rel="stylesheet">
<link href="../vendors/datatables.net-responsive-bs/css/responsive.bootstrap.min.css" rel="stylesheet">
<link href="../vendors/datatables.net-scroller-bs/css/scroller.bootstrap.min.css" rel="stylesheet">

<script type="text/javascript">
$(document).ready(function () {
    $('#table_id').dataTable();
});

</script>

// JQuery Reference, If you have added jQuery reference in your master page then ignore,
// else include this too with the below reference


<link rel="stylesheet" href="https://cdn.datatables.net/1.10.4/css/jquery.dataTables.min.css">
<!-- Custom Theme Style -->
<link href="../build/css/custom.min.css" rel="stylesheet">
</head>

How to print table footer on last page only?

0
0

I'm using the Buttons extension, Print option and I only want the table footer <tfoot> to print on the last page. I tried to just put it in a row <tr><td> at the end of the table, but that doesn't work when I use a custom sort. Any ideas on this?

Viewing all 79328 articles
Browse latest View live




Latest Images