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

Data Range Filter


Editor (license 1.7) server-side columns search

$
0
0

Hi!

I'm trying to get SERVER-SIDE column searching to work.

But when I search for something, it filters only on screen (not in entire database table).

Can anyone give some insight?

My SQL table has +250K records. I need to search by color, by reference, by price, etc.

My Editor license is 1.7.3. My Server-Side script uses EDITOR->class:

    use
        DataTables\Editor,
        DataTables\Editor\Field,
        DataTables\Editor\Format,
        DataTables\Editor\Mjoin,
        DataTables\Editor\Options,
        DataTables\Editor\Upload,
        DataTables\Editor\Validate,
        DataTables\Editor\ValidateOptions;

I used this example ( https://datatables.net/extensions/fixedheader/examples/options/columnFiltering.html ) to achieve COLUMN FILTERING.

        $('#Products thead tr').clone(true).appendTo( '#Products thead' );
        $('#Products thead tr:eq(1) th').each( function (i) {
            $(this).html( '<input type="text" />' );

            $( 'input', this ).on( 'keydown', function (ev) {
                if (ev.keyCode == 13) { //only on enter keypress (code 13) {
                    if ( ProductsTable.column(i).search() !== this.value ) {
                        ProductsTable
                            .column(i)
                            .search( this.value , true, false ) 
                            .draw();
                    }
                }
            } );
        } );

And the PHP script receives this POST when I type some search in PRODUCT_COLOR column: [white|blue]

 POST_Array
 (
     [draw] => 1
     [columns] => Array
         (
             [0] => Array
                 (
                     [data] => id
                     [name] =>
                     [searchable] => true
                     [orderable] => true
                     [search] => Array
                         (
                             [value] =>
                             [regex] => false
                         )

                 )

             [1] => Array
                 (
                     [data] => product_name
                     [name] =>
                     [searchable] => true
                     [orderable] => true
                     [search] => Array
                         (
                             [value] =>
                             [regex] => false
                         )

                 )
             [2] => Array
                 (
                     [data] => product_color
                     [name] =>
                     [searchable] => true
                     [orderable] => true
                     [search] => Array
                         (
                             [value] => white|blue
                             [regex] => true
                         )
                 )
         )

     [order] => Array
         (
             [0] => Array
                 (
                     [column] => 0
                     [dir] => desc
                 )

         )

     [start] => 0
     [length] => 18
     [search] => Array
         (
             [value] =>
             [regex] => false
         )

 )

get a count of records matching a value

$
0
0

I have a table that should have a unique column value for each row. I want to prevent new data entry if a row exists with this unique key value already.. my thought was i could validate on submit, something like this:

// second column should be unique
var total = dt.columns(1).search( newRowKeyToFind ).count();
if (total > 0) return false or alert of issue ...

I read the API says search won't actually execute until the draw() method is called, so I tried using the Filter API, but can't get the value to match or find any examples on usage for the scenario I illustrated above.

Can somebody please help with some simple code for this?

api to get a list of records including those from different pages

$
0
0

Hi All:

I have a datatable that have 100 records with a balance field where the user have to enter for each record.
It is set to 10 records per page. Therefore there is 10 pages.
If the user click on page 9 and entered a balance on page 9 and the user click back page 1.
I expect on page to get all of the balances being entered by the user including page 9?
Is there an ap to do that?

Any help or hint will be greatly appreciated it!!!

datatables api to go to different page

$
0
0

Hi All:

I have a datatable that have 100 records with a balance field where the user have to enter for each record.
It is set to 10 records per page. Therefore there is 10 pages.
Does datatables have an api where I can used in JAVASCRIPT TO GO TO PAGE 3 OR PAGE 4 WITHOUT THE USER CLICKING ON PAGE 3 OR PAGE 4?

Any help or hint will be greatly appreciated it!!!

"COPY" button

$
0
0

Hello. I’ve tried hard to find the answer for this before posting in DataTables. When clicking the ‘copy’ button the result also copies the page name of the website and adds a blank row in between the data and the page name. I have been trying to find a way to have the copy button only copy the the table headers and data without adding the page name at the top and a blank row at the of the copied data. Its frustrating because when I download as CSV it only downloads the headers and data of the table – which is what is wanted. Why does COPY add the blank row and the page title? Thank you in advance for any help and support on this.. I am actually using DataTables via Google Inline Spreadsheet Viewer for WP.

PDF export images

$
0
0

Hi to all,

I exported the table data into pdf.I have an image column in the table.
After exporting this column appears as blank column instead of holding images.

How i can encode my images to base64 format?

This is a repeated question.I am unable to get pdfmake API site.

Thanks

Subi

Can I show images as data in datatables?


By default, display table empty unless a filter on the data returns matches ... How do I do it?

$
0
0

Greetings, I want to ask you about a behavior that they asked me exclusively to achieve with the DataTables that I do not find how to achieve it.
In my scenario, I retrieve data from a server (node ​​js) that returns data in json format and I have it paged from the DataTables configuration.
But I was asked that the default listing does not show any rows unless a filter is written that has matching results. How I do this?

I'm not sure, but is it possible that the datatables have already downloaded all the records before showing them?

My Config tiene:
bLengthChange: true,
lengthMenu: [[5, 10, 25, 50, -1], [5, 10, 25, 50, "Todas"]],
pagingType: "first_last_numbers",
pageLength: 5,
data: dataSet,
ajax: "/reservas/json/",
sAjaxDataProp: "datos.reservas",

Angular 6 Serverside button click

$
0
0

I have been using datatables for years inside a DurandalJS and KncokoutJS project.
We are now converting to use Angular 6.

If I define a table (below), how can I get the button click event to work? Specifically inside Angular, with a reference to the data of the row? In knockoutJs there was a way to "rebind" the HTML AFTER the server call. I cannot get this to work with Angular.

this.dtOptions = {
ajax: (dataTablesParameters: any, callback: any) => {

                this.myService.myEndPoint(dataTablesParameters).
                    subscribe((resp: any) => {
                        this.myDataCollection = resp.aaData;
                        this.ref.detectChanges();
                        callback({
                                recordsTotal: resp.iTotalRecords,
                                recordsFiltered: resp.iTotalDisplayRecords,
                                data:  resp.aaData
                            });
                    });
            },
            select: true,
            order: [2, "asc"],
            columns: [
                    { data: null,  defaultContent: 'details', orderable: false, class: 'details-control'},
                    { data: null, orderable: false, },
                    { data: "partNumber", orderable: true, },
                    { data: "units", orderable: true },
                    {
                        title: "Display Name",
                        data: null,
                        orderable: true,
                        render: (data, type, full) => `<button (click)="testClick(data.id)">ClickMe</button>`
                    }
                ]
  };

User Permissions: Create multiple checkboxes each related to one bit of an integer field

$
0
0

We have a slew of pages that different users have different access to. Using Datatables Editor, is it possible to create a form that would allow for multiple checkboxes (64 max with 64-bit field) to be created ad related to one field?

The one field is a 'permissions' field, a 64-bit integer. We have it setup so that each bit that is set in the field grants access to a certain web page....like a users privileges in a database. I am hoping to create an admin page that will allow for simple assignment of user permissions via a checkboxe for each bit as opposed to the way I do it now.....manually, directly in the database.

Am I dreaming here or do I click 'Buy Now'?

DataTable Not showing weel after ajax.load table

$
0
0

Hi all, i have an issue within table loaded by ajax load to a modal bootstap 3.

I can initialize de datatable but the size over width thew modal.

Here is how i initialize the table in jquery :

$("body").on("click",".botonAgregarItemRequisicion",function(e){
    var idRequisicion = $(this).attr('data-idrequisicion');
    $('input[id="idRequisicionAgregarItem"]').val($(this).attr('data-idrequisicion'));
    urlToLoad = 'acciones/obtenerAgregarItemRequisicion.php?idRequisicion='+idRequisicion;
    //console.log(urlToLoad);
    $('#modalAgregarItemRequisicion .modal-body-interno').load(urlToLoad,function(){
      

       var table = $('#tablaItemesRequisicion').DataTable( {   responsive: true      } );
       

       
    });
});

The extranger thing is when resize de window, the datatable shows like must be.

Can anyone tell me a clue for this?

thanks in advance.

Purchased and still getting trial info in console log.

$
0
0

Good day,

I just purchased Editor and replaced the dataTables.editor.js and dataTables.editor.min.js files in the editor folder.

There were two "DataTables Editor trial info - 2 days remaining" messages in console, when I replaced the files I'm still getting one, its originating from the datatables.min.js

This datatables.min.js file wasn't provided to be replaced, is there something I'm missing?

Thanks

refresh datatable with data

$
0
0

Hi everyone. I want to ask my problem

     $('.tanggal').datepicker({
            format: "yyyy-mm-dd",
            autoclose:true~~~~
        }).datepicker('setDate', 'today')
          .on('changeDate', function(e){
            tabel.ajax.reload();
          });

        tabel = $('#example').DataTable({
           "processing": true,
           "serverSide": true,
           language: {
                infoEmpty: "No records available - Got it?",
            },
           "ajax": {
               "url": "<?php echo base_url('absensi/datatables_ajax');?>",
               "type": "POST",
               data : {tanggal : $("input[name =tglibadah]").val()}
           },
           columnDefs: [{
                targets: 3,
                searchable: false,
                orderable: false,
                className: 'dt-body-center'

            }]
        });

when i change datepicker, a value date is change. but data on ajax is not change. can anyone see my mistake? thank you

How to upload a slider (carousel) from the database?

$
0
0

I used the following code to upload the images,
I would like to turn these images into sliders, and have an automatic code.
without having to change the name of the image each time.

addimage.php

( <?php $msg = ""; require'connect.php'; // quand tu tape sur le button upload if(isset($_POST['upload'])){ $target = "photos2/".basename($_FILES['image']['name']); $image = $_FILES['image']['name']; $nom = $_POST['nom']; $text = $_POST['text']; $sql = "INSERT INTO slider (image,nom,text) VALUES ('$image', '$nom', '$text')"; mysqli_query($db,$sql); if(move_uploaded_file($_FILES['image']['tmp_name'],$target)){ $msg = "image uploaded successfully"; }else{ $msg = "error_uploaded"; } } ?>

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<!--meta pour un site responsive dans tous les appareilles-->
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags must come first in the head; any other head content must come after these tags -->
<title></title>
<link rel="stylesheet" href="css/font-awesome.min.css">
<link rel="shortcut icon" href="image/icone.png">
<!-- Bootstrap -->
<link rel="stylesheet"href="bootstrap/css/bootstrap.min.css">

<!-- my style css -->
<link href="css/style.css" rel="stylesheet">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.2.0/css/all.css" integrity="sha384-hWVjflwFxL6sNzntih27bfxkr27PmbbK/iSvJ+a4+0owXq79v+lsFkW54bOGbiDQ" crossorigin="anonymous">

</head>
<body>

Add Sliders

</body>
</html>.php

<?php ) ****************************************************************************************************************************** image.php to display the images ( require 'connect.php'; $sql = "SELECT * FROM slider"; $result = mysqli_query($db,$sql); ?>
</style>

<?php while($row= mysqli_fetch_array($result)){ echo "<div id='img_div'>"; echo "

".$row['id']."

"; echo "

".$row['nom']."

"; echo "image"; echo "

".$row['text']."

"; ?>
   <a href="deleteSlider.php?q=<?=$row['id'] ?>"><i class="fa fa-trash-o text-danger" aria-hidden="true"></i></a>

   <a href="editSlider.php?q=<?=$d['id'] ?>"><i class="fa fa-pencil-square-o text-info" aria-hidden="true"></i></a>

      <?php 
      echo "</div>";
      }
  ?>)

Thanks for your help


SQL-Error when adding an entry – never had this problem before

$
0
0

We're recently facing issues when adding a new entry to our table via button. We get the following error:


SQLSTATE[42601]: Syntax error: 7 ERROR: syntax error at or near "as" LINE 1: ...8, $9, $10, $11, $12, $13, $14 ) RETURNING as dt_pkey ^

We never used to have this problem before – and we don't know where it suddenly could come from.
Anybody out here who could help? Thanks!

Kind regards

server side scripting for the postgres(psql) is not working?

$
0
0

I tried using the server side scripting code from the link https://datatables.net/examples/data_sources/server_side
this code works only for the mysql, it does not work for postgres database.
Is there any other sample code which supports the postgres database?
ssp.class file which is must for server-side scripting would be much appreciated if someone can share me the one.
Thanks
Koka

Export to word document

$
0
0

Hi guys

How can i add export to word document. Thanks for the help ☺

Header Columns dropdownlist: reload options on change

$
0
0

Hi,

I've an header that columns have a dropdownlist loaded with unique column values.
Currently I create them in the initComplete, my example:

        initComplete: function () {
            var prog = 0;
            this.api().columns([2,3,4,5]).every(function () {
                var column = this;
                if (column[0] == 2) {var val = 'Numero';}
                if (column[0] == 3) {var val = 'Azienda';}
                if (column[0] == 4) {var val = 'Stato';}    
                if (column[0] == 5) {var val = 'Referente';}
                prog++;
                var select = $('<select id="resizing_select' + prog + '" onclick="stopPropagation(event)" style="max-width:200px"><option value="" selected>' + val + '</option></select>')
                    .appendTo( $(column.header()).empty() )
                    .on('change', function () {
                                               var indexSelect = $(this).prop('selectedIndex');
                                               var val = $.fn.dataTable.util.escapeRegex($(this).val());                                           
                                               if (indexSelect != 0 && val == '') {column.search('^' + val + '$', true, false).draw();}
                                               else {column.search( val ? '^' + val + '$' : '', true, false).draw();}
                                              } 
                       );
 
                column.data().unique().sort().each( function (d, j) {select.append('<option value="' + d + '">' + d + '</option>')});
                
                var selectHidden = $('<select id="width_tmp_select' + prog + '" style="display:none;max-width:200px"><option id="width_tmp_option' + prog + '"></option></select>').appendTo( $(column.header()) );
                var idSelect = "resizing_select" + prog;
                var idTmpSelect = "width_tmp_select" + prog;
                var idTmpOption = "width_tmp_option" + prog;
                $('#' + idTmpOption).html($('#' + idSelect + ' option:selected').text()); 
                $('#' + idSelect).width($('#' + idTmpSelect).width());
            });
        },  

My idea would be to always remove all options of each select and in the drawCallback always load them according to the unique column value but I'm not be able.

initComplete declare on change event for each column, but how can I run "column.data().unique().sort().each(....)" into drawCallback ?

Sorry for my english

How to use colResize together with scrollX when true is used

$
0
0

Only colResize can be used when scrollX is false.

Viewing all 82402 articles
Browse latest View live


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