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

Select2 ad Editor

$
0
0

It would be possible for Editor users to have a complete example to use select2 instead of select especially in edit?.
Using select2 instead of edit without modifying php works perfectly but in the edit mode does not preserve the value of the field...

Field::inst( 'clienti.cli_naz' )
    ->options( Options::inst()
        ->table( 'nazioni' )
        ->value( 'naz_cod' )
        ->label( ['naz_nome','naz_cod'] )
        ->render( function ( $row ) {
            return $row['naz_nome'].' ('.$row['naz_cod'].')';
        } )             
        ->order( 'naz_nome ASC' )
    )   
{
    label: "Nazione",
    name: "clienti.cli_naz",
    type: "select2",
    opts: {
        // placeholder: "",
        allowClear: false,
        initialValue: true,
    },
    // type: "select",
    // def: "IT",
    // placeholderDisabled: true
},          

Thank you,
Giuseppe


Logical OR and First letter

$
0
0

Hello everyone,
First of all, thank for datatable, it's awesome !
I would like to use search by first letter and searching by first letter.
What I already did is that :
$( 'input', this.footer() ).on( 'keyup change clear', function () {
if ( that.search() !== this.value ) {
that
.search('\b'+this.value, true, false )
.draw();
}
} );

which allow me to search by first letter.
The problem is, if I want to use the logical OR (while adding |) the second item isn't searched by first letter.
I tried to split("|") and reconstruct my string in a loop and then search(string) but it doesn't work.
Do I do something wrong ?

search panes - wrong package name included

$
0
0

Hi, thanks for Datatables it's amazing! I'm really looking forward to getting search panes working.

In the datatables.net-searchpanes-dt npm module v1.0.1, there's a couple of typos: one on line 18 where it's trying to require the npm package in camel case (npm packages aren't allowed to be camel case) :

require('datatables.net-searchPanes')(root, $); // should be searchpanes instead of searchPanes

Lines 17-18 in datatables.net-searchpanes-dt/searchPanes.dataTables.js .

... and another on line 17 above it, where it checks to see if $.fn.dataTable.searchPanes is defined :

 if (!$.fn.dataTable.searchPanes) { // should be SearchPanes instead of searchPanes

How can I add in "select inputs" and "text box"

$
0
0

I want to drop down in some columns and text box in some columns

Console.log() MAPPED data after mapping in Editor (CSV Import)

$
0
0

I'm trying to view the data that I have mapped in Datatable Editor (csv import)
as json object.

Can you please help?

Is RowReorder currently not working?

datatables server side select specific row

$
0
0

(I opened similar question in Stackoverflow and got 0 replies. Hopefully someone here would give me a hand...)

Datatable server side with > 17,000 rows. Works very well.
At initializing the datatable, it shows the first 10 rows.

Now I need to dynamically (via Javascript/Jquery) scroll to a specific row which is NOT shown on the page because it isn't part of the 1st 10 rows.

The HTML has an element (id="myUserId") containing the value of a cell in a column named 'Id'. This column contains unique values. (What I show here is just for demoing my problem. In my real project, this "myUserId" element will get its value from a $_SESSION variable).

I need Javascript/Jquery to scroll down and show the 10 rows containing the row with the value of 'myUserId' in its 'Id' column.

Any help would be appreciated!

This is what is shown :

This is what I need :

My code :

<!DOCTYPE html>
    <html lang="en">
    <head>
        <link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
        <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.20/css/dataTables.bootstrap4.min.css">
        <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/responsive/2.2.3/css/responsive.bootstrap4.min.css">
    </head>
    <body class="bg-white">
        <div class="wrapper">
            <div class="container-fluid">
                <div class="jumbotron jumbotron-fluid mr-n2 ml-n2 mb-n2 bg-white rounded">
                <a id="myUserId">34</a>
                    <div class="container border border-dark rounded">
                        <div class="row">
                            <div class="col-md-12 col-md-offset-2 myMargTop20 rounded">
                                <table id="usersTable" class="display table border border-dark table-hover dt-responsive nowrap" cellspacing="0" width="100%">
                                    <thead>
                                        <tr class="myLightPurpleBgColor font-weight-bold">
                                            <td>Id</td>
                                            <td>Full Name</td>
                                            <td>User Name</td>
                                        </tr>
                                    </thead>
                                    <tfoot>
                                        <tr class="myLightPurpleBgColor font-weight-bold">
                                            <td>Id</td>
                                            <td>Full Name</td>
                                            <td>User Name</td>
                                        </tr>
                                    </tfoot>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="overlay"></div>
        <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
        <script type="text/javascript" src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
        <script type="text/javascript" src="https://cdn.datatables.net/1.10.20/js/jquery.dataTables.min.js"></script>
        <script type="text/javascript" src="https://cdn.datatables.net/1.10.20/js/dataTables.bootstrap4.min.js"></script>
        <script type="text/javascript" src="https://cdn.datatables.net/responsive/2.2.3/js/dataTables.responsive.min.js"></script>
        <script>
            $(document).ready(function() {
                var jsTable = $('#usersTable').DataTable({
                    'scrollX': true,
                    'pagingType': 'numbers',
                    'processing': true,
                    'serverSide': true,
                    'ajax': 'datatablesServerSide.php',
                });
            });
        </script>
    </body>
    </html>

My datatablesServerSide.php :

<?php
$table = "users";
$primaryKey = "usrId";
$columns = array(
  array("db" => "usrId", "dt" => 0),
  array("db" => "usrFullName", "dt" => 1),
  array("db" => "usrName", "dt" => 2)
);
$sql_details = array(
  "user" => "root",
  "pass" => "",
  "db"   => "a_my_project",
  "host" => "localhost"
);
require("ssp_with_UTF8.class.php");
echo json_encode(
  SSP::simple($_GET, $sql_details, $table, $primaryKey, $columns)
);

Fixed columns on mobile shows original columns underneath when scrolling horizontally

$
0
0

Hi there,

I noticed when accessing this example on ios 13, you can still see the original columns underneath the fixed one
https://datatables.net/extensions/fixedcolumns/examples/initialisation/two_columns.html

I was wondering if there was a way to ensure that when you scroll horizontally and pull right that the original columns don't appear underneath

One way I was thinking was to make the a css style to color the dataTables_scrollBody cells transparent for the columns that correspond to the fixedcolumn ones


Please delete this (posted by accident)

$
0
0

Please ignore posted by accident

Group by SubTotal and Heading Print on Top of that Group

$
0
0
$(document).ready(function() {
    $('#example').DataTable( {
        order: [[2, 'asc']],        
        rowGroup: {
            startRender: null,
            endRender: function ( rows, group ) {
                var salaryAvg = rows
                    .data()
                    .pluck(5)
                    .reduce( function (a, b) {
                        return a + b.replace(/[^\d]/g, '')*1;
                    }, 0) / rows.count();
                salaryAvg = $.fn.dataTable.render.number(',', '.', 0, '$').display( salaryAvg );
 
                var ageAvg = rows
                    .data()
                    .pluck(3)
                    .reduce( function (a, b) {
                        return a + b*1;
                    }, 0) / rows.count();
 
                return $('<tr/>')
                    .append( '<td colspan="3">Averages for '+group+'</td>' )
                    .append( '<td>'+ageAvg.toFixed(0)+'</td>' )
                    .append( '<td/>' )
                    .append( '<td>'+salaryAvg+'</td>' );
            },
            dataSrc: 2
        }       
    } );
} );

Responsive click event not working properly also details-control is working

$
0
0

I'm using together responsive and detail row but not working when clicking the responsive cell.
Green button click event to working but blue button is not working.
How can I get it to work blue button?

 var columns = [
                { data: null, defaultContent: "", width: "0%" },
                { data: null, defaultContent: "", width: "0%" },
                { data: "Date", width: "15%" },
                { data: "Column1", width: "40%" },
                { data: "Column2", width: "15%" },
                { data: "Column3", width: "15%" },
                { data: "Column4", width: "15%" }
            ];
var columnDefs = [
                {
                    targets: 0,
                    className: 'control',
                    orderable: false
                }
            ];
var responsive = {
                details: {
                    type: 'column'
                }
            };
$('#').DataTable({
                columnDefs: columnDefs,
                columns: columns,
                responsive: responsive,
                data: res,
                buttons: false,
                searching: true,
                paging: true,
                info: true,
                ...other stuffs...
});
  $('#Table tbody').on('click', 'td.details-control', function (e) {
             e.stopPropagation();
             //do stuff...
         });
<table id="Table" class="table table-striped table-bordered dt-responsive" cellspacing="0" width="100%">
                        <thead>
                            <tr>
                                <th></th>
                                <th></th>
                                <th>Date</th>
                                <th>Column 1</th>
                                <th>Column 2</th>
                                <th>Column 3</th>
                                <th>Column 4</th>
                            </tr>
                        </thead>
                        <tbody></tbody>
                    </table>

how can i dynamically add column names in dropdownlist

$
0
0

hi, i ave data table and want to add column names to dropdown list and toggle and relocate the columns

Table interval reload function doesn't preserve current page

$
0
0

Good day (o;

Using now the interval reload function for a table which displays the last visited products on our online shop..

        setInterval( function () {
            table.ajax.reload();
        }, 5000 );

Is there a way to prevent jumping back to page 1 when the reload happens?
Makes difficult to browse through the records (o;

thanks in advance
richard

.net oracle connection

$
0
0

I am trying to connect to an oracle database in my .net project. I am getting an error in the line

using (var db = new Database(settings.DbType, settings.DbConnection))

error is: unable to find the requested .net framework data provider. it may not be installed

do I need add a reference to something?

Multiple header thead rows in excel export?

$
0
0

This is a problem that I have seen spanning all the way back from 2012 online.

I have a table with 1 <thead></thead> tag at the top containing multiple header rows. When I export the spreadsheet, it only exports the last row in the table header. Is there any code I can inject into the source code to get this feature working?

I have seen previous attempts at modifying the course code from various other threads on this site and Stack Overflow and none of them seem to work for me. I found the threads quite vague in their implementation of their code fixes, and I haven't been able to get it to work on my end. And, when I paste the code in I am not even sure what I am changing.

Any ideas on what I can do to get all header rows included in the Excel export?


How to incorporate Datatable in JQuery Onclick Function

$
0
0

I have an li

<li id="clientshowall"><a href="#"><span>Show All Clients</span>

// This Function retrieves all the Clients from my mysql database.

$(function(){
$("#clientshowall").on('click', function(){
$.ajax({
method: "GET",
url: "client_tables.php",
}).done(function( data ) {
var result= $.parseJSON(data);
var string='

'; /* from result create a string of data and append to the div */ $.each( result, function( key, value ) { string += ""; }); string += '
customer NumberFirst Name Last Name Email Address Cell Phone
"+value['customer_number']+ "" +value['first_name']+ "" +value['last_name']+ "" +value['email']+ " " +value['primary_phone']+ "

';
$("#payments").html(string);
});
});
});

See Attached of the table.

I would like to use datatables in the above function, but I do not know how to incorporate into this function. If some one caould give me a pointer I would be most appreciative.

thanks

Column menù

$
0
0

I'm looking for a functionality like the one shown in this page that is available for another library. Is there any chance to have something similar in DataTables?

using Editor version, question about simple inline editing example

$
0
0

Hello all,

so I've been playing around with creating basic apps. I can use DataTables to view my tables in an app, it displays and scrolls fine, but I want to add inline editing so I can edit or add data to the table. The table is in an html file using html tags. So I have a few questions....

  1. I downloaded the trial version of editor and I like the example for Simple Inline Editing, it looks good for my needs, but it uses ajax/php and i'm going to be using this in an app. Is there another similar example which can do everything in the phone without a server? I just need it to pull in the html table, and be able to edit cells.

  2. i'm gonna try and use a form to add new rows to the html table, i'm guessing there's no examples of that, but thought i'd ask just in case....

  3. is there a way to apply the dataTables JavaScript to a separate html file with a table in it? It only works for me if I have the table in the same html file as the dataTable JavaScript (using #example). I tried using !table.html#example but no luck.

Any help is appreciated, Thanks!

Can an editor field of type "Checkbox" have a string value?

$
0
0

I'm receiving an error when submitting the following field in editor. Is my approach of assigning a string value to a checkbox incorrect?

"label": "user_type",
"name": "accounts.user_type",
type: "checkbox",
options: [
{
label: "Admin",
value: "admin",
}
],

Handle editors upload field exceptions

$
0
0

Hey,

I'm using ajax object configuration for upload type of input. Everything works great, I just have an issue where if validation of uploaded image is rejected, server returns status code 422, so datatables displays "A server error occurred while uploading the file".

For other ajax requests I was able to handle this inside "error" function, but in this case it doesn't seem to be fired. Bellow is my code:

{
    label: 'Image:',
    name: IMAGE_NAME,
    ajax: {
        url: route('dt.post'),
        type: 'POST',
        data: (data) => {
            data._token = window.Laravel.csrfToken;
        },
        dataFilter: function (response) {
            const json = JSON.parse(response);
            $.each(json.files, function ( table, files ) {
                $.fn.dataTable.Editor.files[table] = files;
            });
            return response;
        },
        error: function (xhr, e/*, thrown*/) {
            let data = xhr.responseJSON;
            if (data && data.hasOwnProperty('fieldErrors')){
//                success(data);
            } else {
//                error(xhr, e, thrown);
            }
        }
    },
    type: 'upload',
    display: function ( file_id ) {
        ...
    },
    clearText: "Clear",
    noImageText: '-'
}

Any idea why error function is not fired when server code != 200?

Beside this approach I also tried to use ajax function instead of object function(method, url, data, success, error) (I use this as default method all over the project) so that I was able to call success or error callback, depending on what happened. If I add this to my upload field, upload field will completely ignore function and just make a POST request to the same page user is currently on. This works for DataTables data calls though, so not sure why it doesn't here...

Is there a way to handle validation errors and prevent "A server error occurred while uploading the file" getting displayed for upload field?

P.S.: After using DataTables for 5+ years I think, I think I could easily say it's one of the most advanced and flexible packages I ever used. GJ Allan and team :)

Viewing all 81691 articles
Browse latest View live


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