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

Scollable column widths - Chrome ok, Firefox and IE-WTF?

$
0
0

Ok, obviously im using Datatables. and i am also using the scroll able plug in.

While everything seems to work fine in Chrome, in Internet explorer, and Firefox, stuff is full of WTF. here is my code:

$(document).ready(function(){
 var CaseNotes = $("#casenotes").DataTable({
        ajax: function (d, c, s) {
            var options = {
                data: d,
                callback: c,
                url: base_url + '/CaseManagement/list_case_notes'
            };
            var url = window.location.href;
            var index = url.lastIndexOf("/");
            options.data.caseid = url.substring(index + 1);
            $.DataTablesRequest(options);
        },
        serverSide: true,
        responsive: true,
        searching: false,
        columns: [
            {data: "noteid", class: "nodisplay"},
            {data: "notedate", width: "10%"},
            {data: "issues", width: "10%", createdCell: function (td, cellData, rowData, row, col) {
                    $(td).addClass('cnissues').addClass('vtop');
                }, class: "cnissues"
            },
            {data: "timespent", width: "15%"},
            {data: "note", createdCell: function (td, cellData, rowData, row, col) {
                }, class: "cnissues", width: "55%", render: function (data, type, row, meta) {
                    return "<div class='cnnotes'>" + data + "</div>";
                }
            },
            {data: "lastedit", width: "10%"}
        ],
        columnDefs: [
            {
                className: 'noselect vtop',
                targets: "_all"
            }
        ],
        "order": [[1, "asc"]],
        dom: "rtiS<\"clearfix\">",
        deferRender: true,
        scrollY: 500,
        scrollX: false,
        scrollCollapse: true,
        scroller: {
            loadingIndicator: true,
            displayBuffer: 10
        }
    });
});

the column width on chrome are acceptable id (hidden): 44px, 77px, 77px, 132px, 581px, 76px.

Fire Fox and Internet explorer don't seem to pay any attentions at all. FireFox: id (hidden):44px, 146px, 146px, 237px, 266px, 146px IE: id (hidden):44px, 133px, 198px, 198px, 267px, 146px

Has anyone else had this? anyone know any solution to this?


Issue scrollHeadInner. Bad column alignment

$
0
0

Hi !

I didn't find where to pose the "issue" so i'll put it here.

I had an alignment problem on the datatable while using the "scrollY" property. In fact, the table header's width (without scrollbar) was the same as the table body, but with the scrollbar. That causes a bad alignment of the columns.

I noticed that there was a "padding-right: 16px;" (16px is exactly the width of the scrollbar) on the header, but the header's width was from 100% so that padding was useless.

I finally managed to fix this by changing the header's width's value in the jquery.dataTables.js (on line 3672). I set the sScrollHeadInner's width to 'auto' instead of the 100%.

Works fine for me now !

Uncaught TypeError: Cannot read property 'aDataSort' of undefined

$
0
0

Hi all!

Hope, it may help someone else.

I had several tough hours trying to sort this issue out. And yes, it only happened due to inattention. So I caught that painful error having pretty simply example:

<head>
<script>
    $( document ).ready( function() {

        $( '#users_table' ).DataTable( {
            "order": [[ 5, "asc" ]],
            "lengthMenu": [5, 10, 20]
        });

    });
</script>
</head>

<body>
<table class="display dataTable" id="users_table"> 
    <thead> 
        <tr> 
            <th>User Id</th>
            <th>User Name</th>
            <th>User1</th>
            <th>User2</th>
            <th>User3</th>
        </tr> 
    </thead>
    <tbody>
        <c:forEach items="${users}" var="users"> 
            <tr>                        
                <td id="${users.userId}">${users.userId}</td>
                <td>${users.userName}</td>
                <td>1</td>
                <td>2</td>
                <td>3</td>
            </tr>
        </c:forEach> 
    </tbody> 
</table>        
</body>

And the answer is pretty simple and had to be obvious. I was stuck dumb. The value of 'order' property is obviously incorrect, having fixed it everything works great!

Cannot use stateLoadCallback to load visibility settings of columns

$
0
0

Hi, I've been trying to use stateSaveCallback to save the state (including visibility settings of columns) to database and then stateLoadCallback to load the previous state. I was able to load the state for column re-ordering, pagination, search terms, and entry number, but I wasn't able to load the state of visibility of columns. There was no "responsive" setting.

The record in the database shows clearly that the column visibility settings were saved correctly, so the only problem is why stateLoadCallback didn't load the visibility settings.

The followings are the code snippets, could you please help me with this? Thanks a lot!

var dt = $('#example').dataTable({
                    stateSave : true,
                    "stateDuration": 60 * 60 * 24*365*100,
                    "scrollY" : "800px",
                    "scrollCollapse" : true,
                    "processing" : true,
                    "serverSide" : true,
                    "ajax" : "loaditems.php",
                    "columns" : [{
                        "className" : "details-control",
                        "data" : null,
                        "defaultContent" : ""
                    }, {
                        "data" : "Name"
                    }, {
                        "data" : "User"
                    }, {
                        "data" : "Date"
                    }, {
                        "data" : "Checked"
                    }, {
                        "data" : "Location"
                    }, {
                        "data" : "Note"
                    }],
                    "order" : [[1, 'asc']],
                    "dom" : 'R<"tips">lf<"clear">Crtip',
                    "stateSaveCallback" : function(settings, data) {
                        $.ajax({
                            "url" : "statesave.php",
                            "data" : data,
                            "dataType" : "json",
                            "type" : "POST",
                            success : function(data) {  
                            }
                        });
                    },

                    "stateLoadCallback" : function(settings) {
                        var o;
                        $.ajax({
                            "url" : "stateload.php",
                            "async" : false,
                            "dataType" : "json",
                            "success" : function(json) {
                                o = json;
                            }
                        });
                        return o;
                    }
                });

$("div.tips").html('<b>Choose to &nbsp;</b>');
    

Table will not redraw after filter or search

$
0
0

I have a table filled at page load with an array of data, and refreshed client-side using yadcf. I've now added a couple of checkboxes for showing/hiding Archived/Cancelled documents from the table.

The filtering callback seems to work fine, it detects the rows that have the searched for value and returns true/false appropriately. However, when I do table.draw(), nothing happens, ever... If I perform a table.order().draw(), it redraws fine, though.

    if (!$(filter).is(":checked")) {
        table.column('th.statuses').data().filter(function(value, index) {
            var text_value = '';
            var filterVal = $(filter).attr('value');

            $(value).find('option[selected="selected"]').each(function(key, item) {
                text_value += $(item).html();
            });

            if (filterVal == '') {
                return true;
            }

            var re = new RegExp(filterVal, 'ig');
            return text_value.match(re) != null ? true : false;
        }).draw();
    }

Do you have any idea why draw() isn't working?

How to hide a button

Fixed Header is not working.

problem with buttons and layout with tabletools library

$
0
0

Hi,

I tried to use table tools library but I have an issue. Buttons is not showing up and also the layout is incorrect. I want the button to be on top on search box.

Please see the capture below : http://picpaste.com/domo-asH7pSu1.png

Version: - DataTable 1.10.6 - TableTools 2.2.4 - Jquery 1.11.1

    <script type="text/javascript" src="js/jquery.min.js"></script>
    <script type="text/javascript" src="js/jquery.dataTables.min.js"></script>
    <script type="text/javascript" src="js/dataTables.tableTools.js"></script>

    $.getJSON("http://" + SERVER + "/ldata/log", function( data ) {
      $(document).ready(function() {
        $('#log').html( '<table class="display compact" id="log-data" width="100%"></table>' );

        $('#log-data').dataTable( {
          "sDom": 'T<"clear">lfrtip',
          "tableTools": {
            "sSwfPath" : "http://cdn.datatables.net/tabletools/2.2.2/swf/copy_csv_xls_pdf.swf"
          },
          "data": data['tbody'],
          "columns": data['thead'],
          "lengthMenu":[[25,200,500,-1],[25,200,500,"All"]],
    });
       });
      });

Is something wrong with the code ? (surely yes...)


Server side Processing and client side sorting & filtering

$
0
0

Hi , I am using Server side processing . If rows length is less than iTotalDisplayLength ,I need sorting and filtering on client side. I tried "bServerSide = false" in that condition but not working. How can I achieve the client side sorting and filtering. Thanks

Offset an Limit

$
0
0

I have a big database and so I don't want to download the full database. So I was looking for a way how I can use the variables form the lengthMenu and the paging so that I can work with Limit and Offset in my SQL syntax. Can anybody please help me ?

Dynamic header and table data

$
0
0

Hi,

I'm using json to dynamically set data and header. I did it like below :

    $.getJSON("http://127.0.0.1/data/info", function( data ) {
      $(document).ready(function() {
    $('#log').html( '<table class="display compact" id="log-data" width="100%"></table>' );

    var table = $('#log-data').dataTable( {   
      "dom": '<"tblContainerT"T><"tblContainerTop"lf><rt><"bottom"ip>',
      "tableTools": {
        "sSwfPath": "/swf/copy_csv_xls_pdf.swf"
      },
      "data": data['tbody'],
      "columns": data['thead'],
      "lengthMenu":[[25,200,500,-1],[25,200,500,"All"]],
      'fnInitComplete' : function () {
        $("thead tr").clone().appendTo($("tfoot tr")) ;
      }
    });
      });
    });

It works fine. However, I noticed footer is not generated and apparently this is because header is generated dynamically (I read it somewhere). So I tried to use 'fnInitComplete' and clone the header columns to the footer. I did it like below :

      'fnInitComplete' : function () {
        $("thead tr").clone().appendTo($("tfoot tr")) ;
      }

Well, it seems its not working and unfortunately it is bit difficult for me to understand what's wrong. Could you point me to the right direction ?

Thanks,

Clear datatable when using server side processing?

$
0
0

Is there an easy way to clear the table when using server side processing? I have tried 10 different things but haven't been able to property clear the data.

I have read in other posts that I have to delete the rows from the server side then requery the server? I don't want to delete anything on the server, I would just like to clear the data from the client. This seems like such a trivial feature and I'm sure plenty of people would use it.

1.10 Sort Column with Numbers and empty Cells

$
0
0

Hello Community,

i need help with sorting numbers in a column with a few empty entries. I want the empty cells allways at the bottom when sorting the table.

I found a few posts here with the same problem and got a few solutions but nothing worked here... For example the numWithNull example from here (http://datatables.net/forums/discussion/9784/sort-columns-with-numbers-and-empty-cells) is not working

Here is an example (test) page

http://chogger.de/work/?p=track_detail_records&id=101

The columns "Race" and "Qualy" are the columns where i need this behavior. Any help would be grear

Destroy not removing enhancements?

$
0
0

http://live.datatables.net/jurezova/1/edit?html,css,js,output

I have a button that destroys and recreates a table (Destroy Table in the example). Clicking on the button destroys the table body, but doesn't remove anything from <thead>.

Each time I do this I end up with an extra: <div class="DataTables_sort_wrapper">Inquriy<span class="DataTables_sort_icon css_right ui-icon ui-icon-triangle-1-n"></span></div> <span class="DataTables_sort_icon css_right ui-icon ui-icon-triangle-1-n"></span>

Am I doing something incorrectly? How can I clear the <thead>?

Thank you!

Multiple Headers in DataTables Editor

$
0
0

Hi,

I'm getting a duplicate header and footer in the DataTables Editor since I switched to version 1.4. Is there a way to disable the second header in the editor form? Here is the html.

<div class="ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix">
<span id="ui-id-7" class="ui-dialog-title">
<div class="DTE_Header_Content">Edit Row</div>
</span>
<button class="ui-button ui-widget ui-state-default ui-corner-all ui-button-icon-only ui-dialog-titlebar-close" role="button" aria-disabled="false" title="close">
</div>
<div id="ui-id-6" class="ui-dialog-content ui-widget-content" style="width: auto; min-height: 28px; max-height: none; height: auto;">
<div class="DTE DTE_Action_Edit">
<div class="DTE_Header" data-dte-e="head">
<div class="DTE_Header_Content">Edit Row</div>
</div>
<div class="DTE_Processing_Indicator" data-dte-e="processing"></div>
<div class="DTE_Body" data-dte-e="body">
<div class="DTE_Footer" data-dte-e="foot">
</div>
</div>

Error making column visible when using scrollY

$
0
0
<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>Test</title>
    <link rel="stylesheet" type="text/css" href="//cdn.datatables.net/1.10.7/css/jquery.dataTables.css">
    <script type="text/javascript" charset="utf8" src="//code.jquery.com/jquery-1.10.2.min.js"></script>
    <script type="text/javascript" charset="utf8" src="//cdn.datatables.net/1.10.7/js/jquery.dataTables.js"></script>
    <script>
        $(function () {
            var dataSet = [
                    ["1", "2", "3", "4"],
                    ["1", "2", "3", "4"],
                    ["1", "2", "3", "4"]
            ];
            example = $('#example').DataTable({
                data: dataSet,
                scrollY: 600,
                columns: [
                    { title: "One", visible: false },
                    { title: "Two" },
                    { title: "Three" },
                    { title: "Four" }
                ]
            });

            example.column(0).visible(true);
        });
    </script>
</head>
<body>
    <table id="example" class="display" cellspacing="0" width="100%">
    </table>
</body>
</html>

Results in

Uncaught TypeError: Cannot read property 'style' of undefined
_fnCalculateColumnWidths @ jquery.dataTables.js:4165
_fnAdjustColumnSizing @ jquery.dataTables.js:764
__setColumnVis @ jquery.dataTables.js:8292
(anonymous function) @ jquery.dataTables.js:8370
_Api.iterator @ jquery.dataTables.js:6905
(anonymous function) @ jquery.dataTables.js:8366
(anonymous function) @ jquery.dataTables.js:7154
_Api.extend.methodScoping @ jquery.dataTables.js:7038
(anonymous function) @ test.html:28
x.Callbacks.c @ jquery-1.10.2.min.js:4
x.Callbacks.p.fireWith @ jquery-1.10.2.min.js:4
x.extend.ready @ jquery-1.10.2.min.js:4
q @ jquery-1.10.2.min.js:4

If I remove the scrollY option, the error doesn't occur.

Custom paging with array of JavaScript objects

$
0
0

I am working on a application which is nicely modularized using requirejs. One of the modules called data service is in charge of providing other modules with data. Pretty much all get* methods of this module return javascript script objects in the the following format:

res = {
    totalRows: 537, 
    pageSize: 10, 
    page: 15, 
    rows: [
        {
            id: 1, 
            name: 'John'
            ...
        }, 
        {
            id: 2, 
            name: 'Michael'
            ...
        }, 
        {
            id: 3, 
            name: 'Stephen'
            ...
        }, 
        {
            id: 4, 
            name: 'Dan'
            ...
        }, 
        {
            id: 5, 
            name: 'Rob'
            ...
        },
                ....
    ]
}

Is it possible to initialize the data table so that it "knows" that we are currently viewing page #15 of total 54 pages and that consequently it builds the pager correctly to allow the user to view other pages.

Thanks in advance!

Zen

sLoadingRecords in 1.8.0

$
0
0

Hello, I'm using datatables 1.8.0, I am unable to activate the sLoadingRecords parâmentro:

javascript

$ (document) .ready (function () {

oTable = $ ('# example'). dataTable ({

"oLanguage": {

                 "sLoadingRecords", "Please wait - loading ..."

                 },

"bJQueryUI": true,

"sPaginationType": "full_numbers"

"bPaginate": false,

"bScrollCollapse": true,

"sScrollY": "400px"

"sScrollXInner", "100%"

}); });

What is wrong?

How to implement update on ruby on rails?

$
0
0

Eu tenho uma rota "PUT /admins/:id " o que passar como parâmetro na minha função

oTable.$('.edit').editable( ' O QUE INFORMAR ', { method: 'put',
"callback": function( sValue, y ) { var aPos = oTable.fnGetPosition( this ); oTable.fnUpdate( sValue, aPos[0], aPos[1] ); }, "submitdata": function ( value, settings ) { console.log(value); return { "row_id": oTable.fnGetPosition( this )[0], "column": oTable.fnGetPosition( this )[2]

        };
    },

    "width": "90%",
    "height": "100%"
} );

Cannot use different language with custom dom

Viewing all 82568 articles
Browse latest View live


Latest Images

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