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

Fixed Columns with Server Side Processing - Columns overlapping?

$
0
0

Hi All,

I've had DT working with left fixed columns for a while without any issues where the table has been loaded in full... i've now re-created the same table using server side processing/AJAX to reduce that initial loading time, but i'm now seeing rendering issues where the last fixed column, and the first 'floating' column overlap - on page 1 this isnt an issue, and it's not an issue on all pages (some of the pages are fine). On most 'broken' pages, the overlap is probably half a character being hidden on the 'floating' column, but on other broken pages i'd say up to 3 or 4 characters are covered - and you cant drag the scrollbar further left to see the data.

I've tried giving the columns minimum widths that exceed the size of any data in them, but that didnt help either...

Has anyone seen this before and know how to fix it?

Thanks for any help :)

Chris


Column not sorting with orthogonal data, only on live site

$
0
0

Hi there,

I've got a datable and I'm using orthogonal data to sort a date field with the sort being a unixtimestamp. The data is being drawn from JSON. Everything works great on dev server however on the live site the sort on the date column does not sort. All other columns sort. The other symptom is that there when you click on the sort there is a noticeable pause, that does not exist on the other columns. The JSON is only about 170 rows, and I can't see anything unusual about the data and it's valid JSON.

Currently using 10.10.7, I've put the column definition. Does anyone have any idea how I should go about debugging this? Are there any known possible culprits?

Many thanks!

''' columns: [ { "data": "display_id" }, { "data": "status_name"}, { "data": "amount" }, { "data":{ "_": "trans_date_human", "sort": "trans_date" } }, { "data": "parent_display_id" }, { "data": "type_name"}, { "data": "isfor_name" }, { "data": "payer_name"}, { "data": "trans_id"}, { "data": "custom_receipt_no"}, { "data": "bank_account_name"}, { "data": "display_id"} ], ''''

Responsive layout when column value is significantly longer than in previous page

$
0
0

Hi,

I have a problem with responsive layout. I have first column used as "title" which can be whatever size from 10 letters to 100 letters.

If there are only short titles in page one and then for example very long title in page two responsive layout does not work. http://live.datatables.net/jehonume/1/edit <- I am not sure if I am giving the link correctly to you? But responsive layout at least also in that example breaks if one name e.g. in page 2 is a lot longer than any of the names in page 1.

So how to use responsive layout to adapt dynamic content (from server-side in my case) so that column 1 gets the priority and responsive layout keeps working?

Thank you!

columnDefs for child rows

$
0
0

Following the example at https://datatables.net/examples/api/row_details.html is there a way to change '1' and '0' to "Yes' and 'No' like can be done with the following code for a parent row?

columnDefs: [
   {
      render: function ( data, type, row )
      {
         if (data === '1')
         {
            return 'Yes';
         } else {
            return 'No';
         }
      },
      targets: [ 4, 5 ]
   },
]

How can I add a background color to a column header?

$
0
0

I need to add a background color to a column header label that only takes the area of the label and not the whole th area. It would be something like this:

<th class="sorting_asc" tabindex="0" aria-controls="DataTables_Table_0" rowspan="1" colspan="1" aria-label="columnlabel: activate to sort column descending" aria-sort="ascending">

<span>columnlabel</span>

</th>

Installation Problem using Datatables and bootstrap (nothing changes)

$
0
0

Hi, I am trying to use the CDN to setup a table with DataTables but nothing is happening.

The table does not change whatsoever. It stays exactly as it was before I added the lines it shows in the installation manual.

Below is some code.

<!-- DataTables CSS -->

***************at the top***************

    <link rel="stylesheet" type="text/css" href="//cdn.datatables.net/1.10.10/css/jquery.dataTables.css">

    <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/s/bs/dt-1.10.10,af-2.1.0,b-1.1.0,b-colvis-1.1.0,b-print-1.1.0,cr-1.3.0,fh-3.1.0,r-2.0.0,rr-1.1.0,sc-1.4.0,se-1.1.0/datatables.css"/>

***************table******************

<div class="row">
                    <div class="col-lg-12">
                        <h2>Customers</h2>
                        <div class="table-responsive">
                            <table id="table_id" class="table display table-bordered table-hover table-striped">
                                <thead>
                                    <tr>
                                        <th>id</th>
                                        <th>First Name</th>
                                        <th>Last Name</th>
                                        <th>Phone Number</th>
                                        <th>Company</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <tr class="active">
                                        <td>12</td>
                                        <td>Daniel</td>
                                        <td>M</td>
                                        <td>777-777-7777</td>
                                        <td>Company</td>
                                    </tr>
                                     ...
                                     ...
                                     ...
                                </tbody>
                            </table>
                        </div>
                    </div>
                    
                </div>



***************bottom******************
<!-- DataTables JavaScript -->
    <script type="text/javascript" charset="utf8" src="//cdn.datatables.net/1.10.10/js/jquery.dataTables.js"></script>

    <script type="text/javascript" src="https://cdn.datatables.net/s/bs/dt-1.10.10,af-2.1.0,b-1.1.0,b-colvis-1.1.0,b-print-1.1.0,cr-1.3.0,fh-3.1.0,r-2.0.0,rr-1.1.0,sc-1.4.0,se-1.1.0/datatables.js"></script>

<script>
    $(document).ready( function () {
        $('#table_id').DataTable();
    } );
    </script>

    <!-- jQuery -->
    <script src="js/jquery.js"></script>

    <!-- Bootstrap Core JavaScript -->
    <script src="js/bootstrap.min.js"></script>


If you need additional information please let me know. I'm still learning so thanks in advance for any and all help.

Bootstrap tooltips don't work in page different from the first of datatables

$
0
0

I'm developing several datatables where the cells of some columns have bootstrap tooltips. So i'm using:

Bootstrap framework
Datatables.

The Datatables is organized in several pages. When the document is ready and the table is loaded, in the first page of the datatables the tooltips are working fine, but the cells of the nexts pages have no tooltips!

How can I solve this problem?

Starting Inline Editing on pressing the Enter

$
0
0

I was happy to find this example about triggering inline editing when enter (key 13) is beeing pressed. https://datatables.net/reference/event/key

Obviously I want Inline editing to be started on pressing the enter key on the keyboard.

Unfortunately (in my case) the enter key will trigger the Editor.prototype.submit event causing the inline state te close immediatly after starting. I checked all this debugging in javascript step by step. So I know the inline editing starts correctly.

Is there anyway of preventing this? I have tried originalEvent.preventDefault() which works on any other key then the enter??

Here is my code:

      table

            .on('key', function (e, datatable, key, cell, originalEvent) {
                    switch(key) {
                        case 13:
                            //ENTER KEY DOES NOT WORK !?
                            var response = editor
                                .one('close', function () {
                                    table.keys.enable();
                                }).inline( cell.node(), { submit: 'allIfChanged' } );
                            table.keys.disable();

                            originalEvent.preventDefault();

                            break;
                        case 78:
                            //'N' KEY DOES WORK !!!
                            var response = editor
                                .one('close', function () {
                                    table.keys.enable();
                                }).inline( cell.node(), { submit: 'allIfChanged' } );
                            table.keys.disable();

                            originalEvent.preventDefault();


                            break;
                        default:
                            //console.log('Key press: ' + key + ' for cell ' + cell.data());
                    });

Sorting filtered data

$
0
0

Is it possible to sort the newly filtered data? For example, if I have 100 records and on the search box I begin typing a key word and my results are now filtered down to 25 records; is it possible to apply a sort on the 25 records based on a condition?

In my use-case I have a hidden column with a numeric value I need to sort the results based on.

Hide/show rows based on class

$
0
0

Hey,

I think this has probably been asked before, but couldn't find an answer for my case.

I have multiple tables on a page. The user can delete and restore rows.

Due to the restoring feature, simply removing a row is not suitable as the data would be gone for them to restore. So I'm currently using native jQuery hide/show functions to achieve this.

As it's an intranet it's not easy to post a link. The process is this:

On page load, data is pulled from a database. All records are returned, including those flagged as 'deleted'. The rows flagged as deleted get given a table row class of 'deleted' so are not shown. CSS styles this class as display: none.

The user then presses a button to show deleted rows, which includes a button to restore the row. All that happens is fadeOut > remove the 'deleted' class > fadeIn. Then recount the number of non hidden rows.

Deleting a row is similar: fadeOut > add 'deleted' class to the row. If the show deleted items option is turned on, it fades back in.

var row = $( this ).closest( "tr" );
var elem = row.prop( "tagName" ).toLowerCase();

switch( action ) {

    case "delete":

        row.fadeOut( "slow", function( event ) {

            rowCount = row.closest( "table" ).find( "tbody > tr:visible:not( .deleted )" ).length;
            row.closest( "div.content" ).prev( "div.header" ).find( "h2 > span" ).html( rowCount );
            row.addClass( "deleted" );

        } );

        if( $( "#deleteditems" ).val() === "show" ) {

            row.fadeIn( "slow" );

        }
        break;

    case "restore":

        row.fadeOut( "slow", function( event ) {

            row.removeClass( "deleted" );

        } ).fadeIn( "slow", function( event ) {

            rowCount = row.closest( "table" ).find( "tbody > tr:visible:not( .deleted) " ).length;
            row.closest( "div.content" ).prev( "div.header" ).find( "h2 > span" ).html( rowCount );

        } );
        break;

}

I'm guessing there's a (much) better way to do it natively in DataTables?

Thanks

Don't work sorting table

$
0
0

Why the sorting column don't work with (ex.) 'dd/MM/yyyy' format date?

Can I move the search box to the left?

$
0
0

Hi,

Using the Bootstrap styling... Can I move the search box to the left? And once I do that, can I remove the word "Search" and the colon? And once I do that, maybe add placeholder text inside the box?

Thanks!

Confused about which css files I need

$
0
0

I'm looking back at an older project which had datatables and I noticed I'm using "jquery.dataTables_themeroller.css" from a microsoft cdn.

I can't find a reference to this file on the DataTables site anymore and am not sure if I need it. But when I remove it, it screws up the styling of the table. I got DataTables from NPM now and it doesn't include that file. I am using: 'jquery-ui/themes/vader/jquery-ui.css').

Get rows after sorting

$
0
0

Hi,

Great plugin!! But I have a problem with getting the right data back after sorting.

        datatable.data().each(function(index, value) {
            console.log($(index[0]).prop('id') + ' ' + value);
        });

Gives me one row and the first id attrbute of node. The problem rises when I sort the list. The loop gives me exactly the same data, even ordering/sorting have changed.

Please help!

NEW, EDIT, DELETE successfully but with error Undefined variable data

$
0
0

Hi all,

I have this big problem.

I have added in the ajax query an ID to send to the db.php file but with this method datatables give me an error. What I can do?

This is my code:

dialog.php

<?php
$id = $_REQUEST['id'];
echo $id;
?>

var editor5;
var ids = <?php echo $id; ?>;
$(document).ready(function() {

editor5 = new $.fn.dataTable.Editor( {
   "bServerSide": true,
        ajax: "php/manutenzione2_db.php",
        table: "#example5",
        fields: [ {
                label: "First name:",
                name:  "manutenzione_SUBCAT.id"
            }, {
                label: "Last name:",
                name:  "manutenzione_SUBCAT.nome"
            } , {
        label: "ids",
                name: "manutenzione_SUBCAT.id_manutenzione_CAT2",
                type: 'hidden',
                def: ids
            }
     ]
} );
  
$('#example5').DataTable( {
    dom: "Bfrtip",
  "bServerSide": true,
        ajax: {
            url: "php/manutenzione2_db.php?IDS="+ids,
            type: 'POST'
        },
        columns: [
            { data: "manutenzione_SUBCAT.id" },
            { data: "manutenzione_SUBCAT.nome" }
      
        ],
        select: true,
        buttons: [
            { extend: "create", editor: editor5 },
            { extend: "edit",   editor: editor5 },
            { extend: "remove", editor: editor5 }
        ]
    } );
} );

</script>

<div><p></p></div>
<table id="example5" class="display" cellspacing="0" width="100%">
  <thead>
    <tr>
      <th>ID</th>
            <th>NOME</th> 
      </tr>
  </thead>
    <tfoot>
        <tr>
            <th>ID</th>
            <th>NOME</th>
        </tr>
  </tfoot>
</table>

AND db.php


if (isset($_GET['IDS'])) { $ID_MANUTENZIONE = $_REQUEST['IDS']; } Editor::inst( $db, 'manutenzione_SUBCAT' ) ->field( Field::inst( 'manutenzione_SUBCAT.id' ), Field::inst( 'manutenzione_SUBCAT.nome' ), Field::inst( 'manutenzione_SUBCAT.id_manutenzione_CAT2' ) ) ->where( 'id_manutenzione_CAT2', $ID_MANUTENZIONE) ->process($_REQUEST) ->json();

I have 400 error when accessing ajax.

$
0
0

When accessing two sites accessing cookies mixed and got 400 error when accessing second time . 1. access first site working fine now moving to second site and login coming to fisrt and trying to access got 400 error .

Suggest how to modify data tables cookies

How to enable a custom button if any of its row selected and vice versa ?

$
0
0

I have a custom bootstrap button that has to be enabled if any of the table row is selected and have to disable it when none of the row is selected. Any Ideas ?

is it possible to reduce the table width?

$
0
0

the datatables table looks good if set to 100% width in the table html tag, but sometimes there aren't so many columns and on a large screen, the data look a bit lost on such a wide table, so I'd prefer to set it to automatic width ... but when I comment out the 100%, the header and the data of the table get out of sync, and the resulting table is completely garbled. Apparently this only happens when the table fits on the screen in its entirety and horizontal scrolling is not necessary - when I output the table on a narrow screen and horizontal scrolling is necessary, the table looks good.

Search query in serverSide mode

$
0
0

When in server side mode if when the table is initially drawn a custom search query is sent to the back end like so

$('#example').DataTable( { "processing": true, "serverSide": true, "ajax": { "url": "scripts/server_processing.php", "data": { "searchQuery" : "red cars" } } } );

How do i make sure that any ajax requests made for pagination also include the exact same query?

When I unhide all columns, after hiding each column with colvis, the overall table width changes

$
0
0

For instance, if the initial table width is 500px when the table is first drawn, if I then hide each column individually with colvis then unhide each column with colvis, I get a table with an overall width of 200px or so. Any ideas why this is happening? how can I get it so the table is 500px again?

Viewing all 82572 articles
Browse latest View live


Latest Images

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