Quantcast
Viewing all 81966 articles
Browse latest View live

Use my own function on datatables server side

HI at all, sorry for english, i have problem woith large amount of data i want use my own function on datatable but something dont work .I include my classes and try to call the function method for example :

This is client side datatable :

<td>

           <a href='crea_corse_autista_interno.php?id=<?=$row['id_corse_autista_interno']?>' class='btn btn-primary btn-xs'><i class='fa fa-pencil'></i></a>
           <a href='elimina_corse_autista_interno.php?id=<?=$row['id_corse_autista_interno']?>' class='btn btn-danger btn-xs' onClick="return confirm('Sei sicuro di voler eliminare il record?');"><i class='fa fa-trash-o'></i></a>

           <a href='duplica_corsa.php?id=<?=$row['id_corse_autista_interno']?>' class='btn btn-primary btn-xs'><i class='fa fa-files-o'></i></a>
        </td>
<td><?=$row['numero_corsa'].' DEL '.$gest_date->data_uk_to_it($row['data']) ?></td>
<?php $autista=$autisti_interni->recupera_da_id($row['id_autista_interno']) ?>
<td> <?=$autista->username?></td>

<td>
   <?php
  $richiedente=$clienti->recupera_da_id($row['id_azienda_richiedente']);
   ?>
       <?php if(!empty($richiedente)){
            echo  $richiedente->ragione_sociale   ;
        }else {
            echo '';
        }

   ?>
   </td>

I Try to use my own function like this :

$columns = array(
array(
    'db'        => 'id_corse_autista_interno',
    'dt'        => 0,
    'formatter' => function( $d, $row ) {
        return "<a href='crea_corse_autista_interno.php?id=".$d."' class='btn btn-primary btn-xs'><i class='fa fa-pencil'></i></a>
           <a href='elimina_corse_autista_interno.php?id=".$d."' class='btn btn-danger btn-xs' onClick=\"return confirm('Sei sicuro di voler eliminare il record?');\"><i class='fa fa-trash-o'></i></a>

           <a href='duplica_corsa.php?id=".$d."' class='btn btn-primary btn-xs'><i class='fa fa-files-o'></i></a>";
    }
),
array( 'db' => 'numero_corsa', 'dt' => 1 ),
array( 'db' => 'data',
       'dt' => 2,
       'formatter' => function( $d, $row ) {

        return date( 'd/m/y', strtotime($d));             }


),
array( 'db' => 'id_autista_interno',  'dt' => 3,

        'formatter' => function( $d, $row ) {

        return $autisti_interni->recupera_da_id($d)->username;             }
 ),
array( 'db' => 'id_azienda_richiedente',   'dt' => 4 )


);

But have error Invalid JSON response ( on return $autisti_interni->recupera_da_id($d)->username; )

How can i use my own function ?

Tanks


Row insert performance on IE

I know I know, it's been talked about to death.
First question, because I cannot find the place in code:

1) Does DT create all the html for a page first and then insert it into the dom, or does it push each row into the dom separately?

Set background color of column

I would like to change the background color of columns that are editable, but when I do this using the classname, it also changes the background color of that column's header, which I don't want. Is there a way to highlight the td cells but not the th? This is how I currently have it:

DT column
{ "data": "UserFlag", "className": "table-cell-edit" }

CSS
.table-cell-edit{
    background-color: lightgoldenrodyellow;
}

When pipelining data using ajax, how can I refresh table with new data?

draw() method not working on multiple table

Dear Team,
I have strange situation with [table.row($(this).parents('tr')).remove().draw(); ] method it working with one of the table on the same page but not for the other
Please help
http://debug.datatables.net/oculif

Server Side Processing

I have a requirement where i need to use Server Side Processing to retrieve the data from .NET Web Service/SQL because i have huge set of data to retrieve. To handle this volume, i am planning to use server side processing with paging, sorting so that it will retrieve only small amount of data at a time and further set will be retrieved on click of next page or sorting.

I saw few of the examples but appreciate if you any one give complete example of Ajax call with .NET Service using Server Side Processing.

I wanted to retrieve only 50 records at a time, on click on next paging or sorting then further records should come.

Thanks
Kannan B

i need auto fill and select functionality some selected column is it possible allan???

i have 12 filed in table and i need auto fill,key table,and select functionality some selected column is it possible allan????

please explain.......

Putting together different data from different tables

That the situation:
I have three different table, i must arrange an array with data from this table...

Here a part of Json to better explain

"data": [
    {
      "DT_RowId": "row_150",
      "ol": {
        "id": "150",
        "ol": "0",
        "fase": "8",
        "centrale": "roma",
        "Data_Inizio": "2017-11-17",
        "Data_Fine": "2017-11-17",
        "cliente_id": "3",
        "fatturato": "1",
        "Materiali_id": "",
        "costi_materiali": null,
        "impiegati_id": null,
        "Time_Stamp": "2017-12-06 10:49:51"
      },
      "clienti": {
        "nome": "FastWeb"
      },
      "materiali": [
        {
          "id": "7",
          "codice": "F-LCLC01-DX-B"
        }
      ],
      "movimenti": [
        {
          "id": "355",
          "quantita": "1",
          "materiale_id": "7"
        }

The last part: I have an array in "movimenti" and another in materiali, i "movimenti" i need to use "codice" and not "materiale_id.

Here the queries:

->join(
        Mjoin::inst( 'materiali' )
            ->link( 'ol.id', 'vardisp.olid' )
            ->link( 'materiali.id', 'vardisp.matid' )
            ->fields(
                Field::inst( 'id' )
                    ->validator( 'Validate::required' )
                    ->options( Options::inst()
                        ->table( 'materiali' )
                        ->value( 'id' )
                        ->label( 'codice' )
                    ),

                Field::inst( 'codice' )

            )
    )





   ->join(
        Mjoin::inst( 'movimenti' )

            ->link( 'movimenti.ad_ol_id', 'ol.id' )

            ->fields(
                Field::inst( 'id' )
                    ->validator( 'Validate::required' )
                    ->options( Options::inst()
                        ->table( 'movimenti' )
                        ->value( 'id' )
                        ->label( array ('quantita', 'materiale_id' ))

                    ),

                Field::inst( 'quantita' ),
                Field::inst( 'materiale_id' )


            )
    )

and here how I use the data on JS


{data: "movimenti", render: function ( data, type, full ) { return $.map( data, function ( d, i ) { return d.materiale_id +' '+ d.quantita; } ).join( ', ' ); }}

any ideas?
tx a lot


Checkbox in Filter drop-down

Error throwed when using ajax with json object

Hi,

I have a hkptu.json file. And I am using DataTable ajax with json object but when it load the json file, it throwed error as below.

Uncaught TypeError: Cannot read property 'length' of undefined
at jquery.dataTables.min.js:48
at i (jquery.dataTables.min.js:35)
at Object.success (jquery.dataTables.min.js:35)
at i (jquery.min.js:2)
at Object.fireWith [as resolveWith] (jquery.min.js:2)
at A (jquery.min.js:4)
at XMLHttpRequest.<anonymous> (jquery.min.js:4)

Wrong format excel exporting

Hello I'm trying to export to excel but the format for thousand separator is not behaving correctly... When it's a number under 1.000.000 it writes "," as separator, when it's higher than 1.000.000, it writes "." my purpose is having "." always as the thousand separator. This is my code in case it helps... Thank you!

`
this.initTable = function(tableId, options, filters) {
var filterEvents;

if (appname.tableGeneratorFilters && filters) {
  filterEvents = appname.tableGeneratorFilters.init(filters);
}

var defaultOptions = {
  dom: 'ri<"detail-actions"><"table-actions">Bf<"filters"><"live-filters">tlp',
  buttons: [
    {
        extend: 'csv',
        charset: 'UTF-16LE',
        fieldSeparator: ';',
        bom: true
    },
    {
        extend: 'excel',
      exportOptions: {
        columns: ':visible',
        format: {
          body: function(data, row, column, node) {
            var value = $('<span>' + data + '</span>').text();

            return value;
          }
        }
      },
        filename: function(){
            var d = new Date();
            // TODO ... dd/mm/yyyy hh:mm:ss.
            return document.title + ' ' +d.toISOString();
        }
    }
  ],

  scrollX: true,
  columnDefs: [
    {
      orderable: false ,
      targets: "no-sort"
    },
    {
      width: "1%",
      targets: 0 }
  ],
  order: [[ 1, 'asc' ]],
  language: {
    search: "_INPUT_",
    searchPlaceholder: '',
    url: ctx + "/js-i18n/tables-i18n.json"
  }
};
var opts = $.extend({}, defaultOptions, options);

var table = $(tableId).DataTable(opts);`

Alert elements form returned JSON

I am using the following to set the json returned to a global variable

 $('#dtInvoiceDetails')
    .on('xhr.dt', function ( e, settings, json, xhr ) {
           selectedPrintData = JSON.stringify(json);

    } );

the console shows

selectedPrintData = {"data":[{"DT_RowId":"row_10108","inv_list":{"lineID":"10108","InvID":"3113","quantity":"23","barCode":"5555","stockCode":"8686856","size":"77","colour":"","description":"more jjjjjjj","costPrice":"0.00","sellPrice":"5.00","lineTotalNett":"115.00","lineTotal":"0.00","vatRate":"0.00"}}],"options":[],"files":[]}

I have tried

console.log(selectedPrintData[0]['data']['inv_list']['quantity']);
console.log(selectedPrintData[0][data][inv_list][quantity]);

What is the correct way to get thhe returned data into an array then be able to alert the 'quantity' value.

Cheers

Steve Warby

autoFill apply selected column?

autoFill apply selected column? how it's possible????

ordenar campo fecha d/m/Y /moment.min.js y datetime-moment.js

Hola, tengo un campo fecha tipo d/m/Y 15/12/2017 y estoy intentando poder ordenarla pero no lo consigo, he incorporado moment.min.js y datetime-moment.js pero no entiendo bien como usarlo en mi función.

<script src="//cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.3/moment.min.js"></script><!---- Es necesario para el datetimepicker---> <script src="//cdn.datatables.net/plug-ins/1.10.16/sorting/datetime-moment.js"></script>

He visto en los ejemplos que se usa asi:

```$(document).ready(function() {
$.fn.dataTable.moment( 'HH:mm MMM D, YY' );
$.fn.dataTable.moment( 'dddd, MMMM Do, YYYY' );

} );```

Pero no tengo claro donde poner ese codigo en mi funcion, yo creo que en mi caso será algo así.

$.fn.dataTable.moment( 'd/m/Y' );

Gracias

WSO2 IS SAML Response Missing Attribute Statement

I had tried WSO2 Identity Server integrated with QlikSense by SAML 2 Protocol .

The Statckoverflow doesn't allow embed image,Sorry.

I had setted WSO2 SP Configuration and Qliksense Server SAML2 Configuration ,but logs of Qliksense display "Exists SAML Attribute statement : 0".

The SAML authenticate process has Failed in SAML Response to Qliksense。

Also, I just found WSO2 SAML Response missing the tag of "attribute statement " 。

SAML Response(SP:QlikSense): miss attribure statement

WSO2 Log Screnshot

I think the key point is "Invalid AttributeConsumingServiceIndex in AuthnRequest "

Is it any possible edit AttributeConsumingServiceindex in WSO2 Configuration?


autoFill apply selected column? how it's possible????

autoFill apply selected column? how it's possible????

Server side datatables fails on second load in IE11

I am using data tables to output reports on my system. They are activated by an ajax call to get the data which is then passed to the js file to output to the page. this works perfectly on all browsers apart from ie11.
Just a quick note i do not get any error messages at all on other browsers.

What happens is on page load in ie11 i get this error message

Image may be NSFW.
Clik here to view.

but this doesnt stop the the initial report loading when you select it.
When i use the same button to either reload the same report or select a different report
the report crashes and i get this error

Image may be NSFW.
Clik here to view.

when i click into the error to see what the issue is it takes me to this section but the doesnt seem to be a problem that i can find.

Image may be NSFW.
Clik here to view.

and here is the code to display the table

window.table = $($tableName).DataTable({

                // gui defaults
                fixedHeader: {
                    header: false,
                    footer: true
                },
                autoWidth: true,
                filter: true,
                scrollX: true,
                sScrollXInner: "100%",
                responsive: false,
                paging: true,
                pageLength: 10,
                language: {
                    paginate: {
                        previous: '<i class="tk-icon-chevron-left"></i>',
                        next: '<i class="tk-icon-chevron-right"></i>',
                    },
                    lengthMenu: '_MENU_ records per page',
                },
                stateSave: false,
                stateSaveParams: function (settings, data) {
                    data.search.search = "";
                },
                processing: true,
                serverSide: true,
                ajax: function (data, callback, settings) {
                    $('#loading').empty();
                    $.when(reportData($searchValue, data, 0)).done(function (responseInternal) {
                        if (responseInternal == true) {
                            var out = JSON.parse(response);
                        } else {
                            var out = JSON.parse(responseInternal);
                        }
                        if (out.data !== null) {
                            callback({
                                draw: data.draw,
                                recordsTotal: out.recordsTotal,
                                recordsFiltered: out.recordsFiltered,
                                //data: JSON.stringify($response.data)
                                data: out.data
                            });
                            $('#reportTable').find('thead').append('<tr></tr>');
                            $.each(out.totals, function (k, v) {
                                var $total = v;
                                $('#reportTable').find('thead').find('tr').eq(1).append('<th>' + $total.total + '</th>');
                            });
                        } else {
                            $('#reportTable').find('thead').empty();
                            $('#reportTable_processing').hide();
                            $('#reportTable > tbody ').empty().append('<tr><td>No data in this report matches the term "' + data.search.value + '".</td></tr>');
                        }
                    });
                },

                //data: $response.data,
                columnDefs: $response.columns,
            });

Any help would be greatly appreciated

Print DataTable with many columns or big data

I know this has been asked before, probably it's still not possible to make the table responsive to printing/PDF exporting.

But is there a way I can make the columns go to a new page when they don't fit?

My situation: http://prntscr.com/hp2csi

PS: It will not only happen with many columns, but also when I have big values on columns.

FixedHeader column widths don't match row columns when scrolling

Hello,

We use dataTables with the fixedHeader plugin to display big tables. In some tables the width of the header columns doesn't match the columns of the rows. It's funny that on some tables that doesn't happen. However we tried a lot and couldn't find the problem; solutions found through googling didn't solve it.

Do you have an idea what may be the issue?

There is a working example here: https://jsfiddle.net/deliaDua/qjkmszgL/

Best, FD

Wait until function is complete while Table is generating

I made a Table with Ajax and setting the columns like this:

var table = $('#customerTable').DataTable({
        "ajax": {
            "url": "api.php?getUsers&type=customers",
            "type": "GET",
            "dataSrc": ""
        },
        "columns": [
            { "data" : "id" },  // Get User ID
            { "data" : "email" },   // Get User Email
            {
                // Convert Usergroup
                "data" : "usergroup",
                render: function(data){
                    ConvertUserGroup(data).done(function(){
                    });

                }
            },

In my DataBase, usergroup is the id of a group which is in another Mysql table (for example -> 1, 2 or 3).

So I want to convert these numbers into a Bootstrap Badge, thats why i do this line:

ConvertUserGroup(data).done(function(){
});

And the function contains this:

// Convert Account Status
function ConvertUserGroup(usergroupID) {
    $.ajax({
        url: "api.php?getGroups&single="+usergroupID,
        type: "GET",
        dataType: "json",
        success: function(data){
            var returnString = '<span class="badge badge-'+data.groupcolor+'">'+data.groupname+'</span>';
            console.log(returnString);
            return returnString;
        }
    });
}

But this isn't working because i can't use two Ajax methods at once. I can't find a callback for render.

So my Question is, how can i tell to ajax in DataTables (while the columns are creating) that it has to wait until ConvertUserGroup() is finished?

Viewing all 81966 articles
Browse latest View live