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

Exceeding width problem, even with wrapper div.

$
0
0

Hi.

I'm starting to use DataTables, and I'm finding it wonderful. I know this has probably been asked here previously, but I believe my case may be different. I am using DataTables with the following configuration (JavaScript):

var tabeladt = $('#tab-teste-dt').DataTable(
{
    // "paging" : true,
    "pagingType": "simple_numbers",
    // "lengthChange": false,
        // "ordering" : true,
        // "searching" : false,
        // "info" : true,
    "serverSide" : true,
        "processing": true,
        "ajax" :
        {
            "url" : "lista-ajax",
        "type" : "POST",
        "dataType" : "json",
        "contentType" : "application/json; charset=utf-8",
        "async" : true,
        "cache" : false,
        "processData" : false,
        "data": function ( d )
        {
            return JSON.stringify( d );
        }
        },

        "columns" : [
                     {} ,
                     {} ,
                     {} ,
                     // Coluna 4...
                     { "render" : function(data , type , row , meta)
                         {
                            if(data.substr(0, 1) == "H")
                            {
                                return '<img src="/app/imagens/ico-h.png" />';
                            }
                            else if(data.substr(0,1) == "M")
                            {
                                return '<img src="/app/imagens/ico-m.png" />';
                            }
                            else
                            {
                                return data;
                            }
                         } } ,
                     {} ],

        "dom" : 'rt<"nav-dt"pl>',

        "language" : {
            "decimal":        ",",
            "emptyTable":     "Sem dados disponíveis no momento.",
            "info":           "Showing _START_ to _END_ of _TOTAL_ entries",
            "infoEmpty":      "Showing 0 to 0 of 0 entries",
            "infoFiltered":   "(filtered from _MAX_ total entries)",
            "infoPostFix":    "",
            "thousands":      ".",
            "lengthMenu":     "ITENS POR PÁGINA: _MENU_",
            "loadingRecords": "Carregando...",
            "processing":     "Processando...",
            "search":         "PESQUSIAR:",
            "zeroRecords":    "Nenhum registro foi encontrado.",
            "paginate": {
                "first":      "INÍCIO",
                "last":       "FIM",
                "next":       "SEGUINTE",
                "previous":   "ANTERIOR"
            },
            "aria": {
                "sortAscending":  ": activate to sort column ascending",
                "sortDescending": ": activate to sort column descending"
            }
        },

        // Extensão select!
        "select" :
        {
            'style': 'single'
        }
});

Here is my HTML markup:

<div class="conte-tabela" th:fragment="tabela-teste (titulo)">

    <!-- HEADER -->
    <div id="cabecalho">

        <!-- TITLE -->
        <span id="titulo" th:text="${titulo}">Título de tabela</span>

        <!-- OPTIONS BUTTONS -->
        <span id="opcoes">
            <button id="bot-pesquisa"></button><button id="bot-colunas"></button>
        </span>

        <!-- COLUMNS MENU -->
        <ul id="menu-colunas" class="popup-menu">
            <li th:each="col : ${#numbers.sequence(0 , colunas.length - 1)}">
                <label>
                    <input type="checkbox" th:value="${col}" th:text="${colunas[col]}" checked="checked">
                </label>
            </li>
        </ul>

        <!-- SEARCH MENU -->
        <div id="menu-pesquisa" class="popup-menu">
            <input type="text" placeholder="pesquisar por..."/>
        </div>

    </div>

    <!-- TABLE -->
    <table id="tab-teste-dt" class="stripe cell-border">
        <thead>
            <tr>
                <th th:each="coluna : ${colunas}"
                    th:text="${coluna}">
                    nome de coluna.
                </th>
            </tr>
        </thead>
    </table>

</div>

Note: There are some special elements from Thymeleaf (I'm a Java developer).

My CSS file:

.conte-tabela
{
    width: 80%;
    margin-left: auto;
    margin-right: auto;
}

.conte-tabela #cabecalho
{
    background: #474241;
    border-left: 1px solid #312e2d;
    border-right: 1px solid #312e2d;
    border-top: 1px solid #312e2d;

    width: 100%;
    display: table;

    padding: 14px 38px;
    box-sizing: border-box;
    position: relative;

    -webkit-touch-callout: none; /* iOS Safari */
    -webkit-user-select: none; /* Safari */
    -khtml-user-select: none; /* Konqueror HTML */
    -moz-user-select: none; /* Firefox */
    -ms-user-select: none; /* Internet Explorer/Edge */
    user-select: none; /* Non-prefixed version, currently supported by Chrome and Opera */
}

.conte-tabela #cabecalho #titulo
{
    text-transform: uppercase;
    font-size: 10pt;
    font-weight: bold;
    color: white;

    display: table-cell;
    vertical-align: middle;
}

.conte-tabela #cabecalho #opcoes
{
    float: right;
    display: inline-block;
}

.conte-tabela #cabecalho #opcoes button
{
    background-color: #474241;
    border: 1px solid #312e2d;
    box-sizing: border-box;
    color: white; width : 40px;
    height: 40px;
    margin-left: 10px;
    width: 40px;

    background-repeat: no-repeat;
    background-position: center center;
}

.conte-tabela #cabecalho #opcoes #bot-pesquisa
{
    background-image: url("/app/imagens/ico-pesquisa.png");
}

.conte-tabela #cabecalho #opcoes #bot-colunas
{
    background-image: url("/app/imagens/ico-conf.png");
}

.conte-tabela #cabecalho #opcoes button:ACTIVE
{
    background-color: #312e2d;
}

.conte-tabela #cabecalho #menu-colunas
{
    margin: 0;
    padding: 20px;
    position: absolute;

    top: 100%;
    right: 38px;

    border: 1px solid #312e2d;
    background: #474241;

    z-index: 100;
    list-style: none;

    opacity: 0.9;
    display: none;
}

.conte-tabela #cabecalho #menu-colunas li
{
    color: white;
    padding-top: 10px;
    padding-bottom: 10px;
}

.conte-tabela #cabecalho #menu-colunas input[type="checkbox"]
{
    margin-right: 10px;
}

.conte-tabela #cabecalho #menu-pesquisa
{
    margin: 0;
    padding: 20px;
    position: absolute;

    top: 100%;
    right: 38px;

    border: 1px solid #312e2d;
    background: #474241;

    display: none;
    z-index: 100;
    opacity: 0.9;
}

Now, take a look at the attached image, please. See how the table exceeds the imposed width limits. If I uncheck the CSS stylization of "element", it get the right size. How can I fix this?

I am also using a separate CSS file to stylize the table in my way. In the case, I generated a theme for styling, and I'm using it as a style for my table. I copied the code and pasted it into a new file (CSS). This gave me full control over stylization, and created a locale for it. I'm saying this, because I do not know if what I did was correct. Since the DataTables styling file is kinda fat/big, I omitted it here. If it is necessary, I will put it here.

Thanks in advance.


Table generated by ajax does not fetch datatables

$
0
0

I'm use datatables in my project, but when sending ajax and recieve return, my table don't get pagination.

I try this:

function onloadcamp(){
$('#tabela').DataTable();
$("#myModalQuestion").modal('hide');
$("#myModal").modal('show');

    var texto = $("#texto").val();
           var nome = $("#nome").val();
           var datainicio = $("#datainicio").val();

$.ajax({
url: '../production/controller/insertCamp.php',
type: 'POST',
dataType:'json',
data:{nome:nome,texto:texto,datainicio:datainicio},
success: function(retorno){
$("#myModal").modal('hide');
$("#response").html(retorno);
$("#myModalResponse").modal('show');
},

    });

}

not found :neutral:

Classic Asp + Mysql + Ajax Load

$
0
0

Hi, I want to use the following ajax event in classic asp.
https://datatables.net/examples/data_sources/server_side.html

I look at this adrese
Https://datatables.net/development/serverside/asp_classic
But I could not get it working.

My codes
<%
Set cariler= Server.Createobject("ADODB.Recordset")
sql = "SELECT * FROM cari where firma_id="&Session("FIRMAID")&" and onay=1 order by id desc"
cariler.open sql,baglantim, 1, 3
Do While Not cariler.eof

response.write cariler("sirketadi")

cariler.movenext
Loop
%>

please help me

How to drag Whole column instead of only table header in colReorder?

$
0
0

Hi,
I want to drag whole column instead of column header in datatable as shown in colReorder example.

I want to do something like this:-
http://www.danvk.org/wp/dragtable/

You can move whole column in place of column header in that.

how can it is possible in datatable using colReorder.

Is there any extension for dataTable where we can drag th and adjust their respective width?

$
0
0

Is there any extension for dataTable where we can drag table head's border or cell border and adjust their respective width?

pdf button disappeared

$
0
0

{extend: 'pdf', text: 'PDF'}

Hi,
my pdf button isnt showing up anymore. Unfortunatley I cannot say when (after which update) it happened. Every other export button (csv, excel, ...) is still visible!
I already tried the following:

  • changing 'pdf' to 'pdfHtml5'
  • upgrading to Datatables 1.10.13 and Buttons 1.2.4
  • switching declaration order of all files (dataTables.buttons.min.js, pdfmake.min.js, vfs_fonts.js, jszip.min.js, buttons.html5.min.js, ...) ---> by the way: which order is the right one?

nothing brought back my pdf button :/

Any suggestion or is this behaviour already known?

scrollX and scrollY remove table id

$
0
0

Similar to the problem that this individual faced, I am running into issues with scrollX and scrollY options:
https://datatables.net//forums/discussion/17238
I find that accessing and modifying the table by the id doesn't work very well under some circumstances, the id seems to disappear or is behaving like a different element or something.
I've linked an example here:
http://live.datatables.net/xoxixixo/2/
The same problem occurs within the thead elements, id's tags are removed and are no longer referenceable after some time.
Let me know what you think,
Andrew

How can i download the complete source code of the application?


How to fix a PHP Fatal Error: Allowed memory size of XXX bytes exhausted

$
0
0

I have tried to setup server side processing, but cannot seem to get it working. When selecting from a table with 130,000 rows I get a alert message that says the following. DataTables warning: tableid=table Ajax error. Please see http://datatables.net/tn/7

My code is working on smaller tables, one of which has 6,500 records and it handles that OK.

I checked the php logs and see the error below.
FastCGI-stderr: PHP message: PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 36 bytes) in

My code is as below where I have set ServerSide to true and type to Post. Is there something else I still need to do?

$(document).ready(function() {
  $('#table').dataTable( {
    "Processing": true,
    "ServerSide": true,
    ajax: {
        url: 'mysql.php',
        type: 'POST'
    },
    "columnDefs": [ { className: "dt-head-left", "targets": "_all" }  ],
    dom: 'Bfrtlip',
    buttons: [ 'copy', 'excel', 'print'  ]
  } );
} );

Any suggestions would be helpful.

Thanks!
James

Using datatable in salesforce lightning component

$
0
0

Hi,

I am using datatable in salesforce lighting component, its working fine expect I am getting this warning when lightning locker service is enabled.

WARNING: SecureElement: [object HTMLDivElement]{ key: {"namespace":"c"} } does not allow getting/setting the disabled attribute, ignoring!

Locker service in salesforce prevent:

Components from causing XSS and similar security issues
Components from reading other component’s rendered data without any restrictions
Components from calling undocumented/private APIs

I am afraid it might stop working some day.

Thanks,
Rehan

Remove number from pagination

$
0
0

TL;DR
How can I remove the numbers from the pagination and just leave Next and Prev?

~
I'm using the server side processing api but the way I'm displaying the pagination is not based on normal pagination with Mysql, i.e. limit 1, 10

Instead, I'm using limit 10 along with a column count being under a certain number, the first load is under a huge number such as 999999999 the next series of the pagination would need to be lower than the smallest amount from the first series and so on.

Basically, this means i can allow a user to jump from the 1st page to the 4th, for example, so I'd like to remove the numbering in the pagination and simply give them the option to move back and forth through each page.

Just an FYi, running the query like this is much faster and my data is in the millions so i need to do it this way for performance.

Shedules Calendar

$
0
0

Как можно реализовать календарь событий (расписание) на data table?

default sort order

$
0
0

I know this is a stupid question, sorry in advance.
This code is on the example:
$(document).ready(function() { $('#example').DataTable( { "order": [[ 3, "desc" ]] } ); } );

My table is from the generator.

does that code go in the table.tablename.js file?

my .ready function does not seems to ignore it.

Thanks, Wiley

Datatable export option to csv is not fetching all data

$
0
0

Hello forum,

I have used datatable to view 500K table data and used server processing option since the data table is huge,

    <script>
        $(document).ready(function () {
            $('#employee_grid').DataTable({
                "processing": true,
                "serverSide": true,
                "ajax": "server_processing.php",
                "dom": 'lBfrtip',
                "buttons": [
                    {
                        extend: 'collection',
                        text: 'Export',
                        buttons: [
                            'copy',
                            'excel',
                            'csv',
                            'pdf',
                            'print'
                        ]
                    }
                ]
            });
        });
    </script>

Am trying now to use the export option but what am getting is the first 10 records only...
how can I change it so I export all filtered data and not the data shown in the first page only ?

Thanks

Fatal error: Call to a member function insertId() on null

$
0
0

Hi Allan,
would you kindly help me with this please. I get this fatal error using Editor to insert a row into a link table. I have a debug code as well, it is "ohufen".

( ! ) Fatal error: Call to a member function insertId() on null in
E:\xampp\htdocs\lgf\DataTables\php\Editor\Editor.php on line 1596
Call Stack
#   Time    Memory  Function    Location
1   0.0012  154368  {main}( )   ...\actions.php:0
2   0.0752  543584  tblUserCreditor( )  ...\actions.php:106
3   0.0920  922648  DataTables\Editor->process( )   ...\functions.php:730
4   0.0920  922992  DataTables\Editor->_process( )  ...\Editor.php:661
5   0.0932  923944  DataTables\Editor->_insert( )   ...\Editor.php:900
6   0.0932  924232  DataTables\Editor->_insert_or_update( ) ...\Editor.php:1040

UPDATE: Completely changed my approach - I couldn't get Mjoin running for my link table editing - even when I put the focus on the parent table like in this example:
https://editor.datatables.net/examples/advanced/joinArray.html

I still got errors within Datatables and Editor. Is it possible that hese are caused by a bug in the new release? Anyway my issue has been resolved through editing the link table directly as a child table as described in the blog here:
https://datatables.net/blog/2016-03-25

This is my Editor code now. I also appended the link table with an extra column defining the user role for the respective creditor. In that sense it isn't a conventional link table any longer. Consequently I also had to add an id to the link table. Got rid of the Mjoin ...

function tblUserCreditor(&$db, &$lang) {
    if ( ! isset($_POST['user']) || ! is_numeric($_POST['user']) ) {
        echo json_encode( [ "data" => [] ] );
    } else {
        if ($lang === 'de') {
            $msg[0] = 'Feld darf nicht leer sein.';
        } else {
            $msg[0] = 'Field may not be empty.';
        }
        Editor::inst( $db, 'creditor_has_user' )
        ->field(
            Field::inst( 'creditor_has_user.user_id' )->set(Field::SET_CREATE),
        // fourth parameter of options could be a where clause https://editor.datatables.net/manual/php/joins, null or limit
        //https://editor.datatables.net/docs/1.5.6/php/class-DataTables.Database.Query.html
            Field::inst( 'creditor_has_user.creditor_id' )->options('creditor', 'id', 'name'),
            Field::inst( 'creditor_has_user.role' )->validator( 'Validate::notEmpty', array('message' => $msg[0]) ),
            Field::inst( 'creditor.name' )
        )
        ->leftJoin( 'user', 'user.id', '=', 'creditor_has_user.user_id' )
        ->leftJoin( 'creditor', 'creditor.id', '=', 'creditor_has_user.creditor_id' )
        ->where( 'creditor_has_user.user_id', $_POST['user'] )
        ->where( 'user.type', 'C' )
        ->on('preCreate', function ( $editor, $values ) {
            // no acces to $id inside the function - need to access global array again
            $userUser = filter_var($_POST['user']);
            $editor
                ->field('creditor_has_user.user_id')
                ->setValue($userUser);
        })
        ->process($_POST)
        ->json();
    }
}

Modal window in another table

$
0
0

Is it possible to call a modal window in another table? For example, I'm in the product table (active #1), I need to add the new client (table is not active #2). how can you call a modal window clients? I didn't find any information on the forum...

Do you mean showing a form from within another form? I'm afraid that currently that isn't yet possible with Editor. You would need to have a different page for the client information and then be able to select that in the product table.

Modal in another table?

$
0
0

Is it possible to call a modal window in another table? For example, I'm in the product table (active #1), I need to add the new client (table is not active #2). how can you call a modal window clients? I didn't find any information on the forum...

Do you mean showing a form from within another form? I'm afraid that currently that isn't yet possible with Editor. You would need to have a different page for the client information and then be able to select that in the product table.

How to inner join query in ssp.class

$
0
0

I need help to be able to join 2 table to get another field and show

// DB table to use
$table = "usuario_vod";

$joinQuery = "FROM '{$table}' AS uv LEFT JOIN usuario AS ud ON (ud.cve=uv.cve_dealer)";
$extraWhere = "";

// Table's primary key
$primaryKey = 'cve';

// Array of database columns which should be read and sent back to DataTables.
// The db parameter represents the column name in the database, while the dt
// parameter represents the DataTables column identifier. In this case simple
// indexes
$columns = array(
array( 'db' => 'vd.usuario', 'dt' => 0),
array( 'db' => 'vd.apodo', 'dt' => 1),
array( 'db' => 'vd.status', 'dt' => 2 ),
array( 'db' => 'vd.fecha_vencimiento', 'dt' => 3,
'formatter' => function( $d, $row ) {
return date( 'd/M/Y', strtotime($d));
}
),
array( 'db' => 'ud.usuario', 'dt' => 4 ),
array( 'db' => 'vd.idu_dispositivo', 'dt' => 5),
array( 'db' => 'vd.cve_dealer', 'dt' => 6)
);

// SQL server connection information
$sql_details = array(
'user' => 'ro',
'pass' => '',
'db' => 'r',
'host' => 'localhost'
);

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* If you just want to use the basic configuration for DataTables with PHP
* server-side, there is no need to edit below this line.
*/

require( 'ssp.class.php' );

echo json_encode(
Ssp::simple( $_GET, $sql_details, $table, $primaryKey, $columns, $joinQuery, $extraWhere)
);

my query

SELECT
uv.*,
ud.usuario AS dealer
FROM usuario_vod AS uv LEFT JOIN usuario AS ud ON (uv.cve_dealer=ud.cve)

Load/reload data from server

$
0
0

I'm using ASP.NET MVC.

I have this which works to load the data initially

    $(document)
        .ready(function() {

            $('#users')
                .DataTable({
                    paging: true,
                    data: getUsers(),

... etc
});
});

    function getUsers() {
        var users;

        $.ajax(
        {
            url: '@Url.Action("GetUsersJavaScriptArray")',
            type: 'GET',
            cache: false,
            async: false,
            data: {
                appGuid: $('#@Html.IdFor(m => m.SelectedAppUniqueId)').val()
            },
            success: function (data) {
                users = data;
            },
            error: function () {
            },
            complete: function () {
            }
        });

        return users;
    }

But I can't work out how to reload the data when the appGuid has changed.
Using $('#users').DataTable().ajax().reload() gives me "0x800a138a - JavaScript runtime error: Function expected".

If I try to use

            $('#users')
                .DataTable({
                    paging: true,
                    ajax: {
                        url: '@Url.Action("GetUsersJavaScriptArray")',
                        type: 'GET',
                        cache: false,
                        async: false
                    },

....

That fails with a null ref exception.

Any help appreciated.

Ordering only when click on icon

$
0
0

Hi guys,

When I click anywhere on table header (th), the ordering function is called.

How can I do to ordering function be called only if i click on order icon?

Thanks

Viewing all 81393 articles
Browse latest View live


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