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

Removing sort arrows from column header that has select checkboxes in first column.

$
0
0

I need to remove the sort arrows from the column heard that contains checkboxes.

    copyMachineTasksTable = $('#copyMachineTasksTable').DataTable( {

          pageLength: 10,
          searching: false,
          paging: false,
          info: false,
          ordering: false,

          ajax: {
                   type: 'POST',
                   url: "MachineTaskManagement/ssp_TaskManagement.php",
                   data: {locationCode: userLocationCode,
                          machineCode: $("#copyTasksMachineSelectionDialogModal_machineCode").val()},   
                   cache: 'false',
            },
        columnDefs: [
                 {
                    targets: 0,
                    checkboxes: {
                    selectRow: true,
![](https://datatables.net/forums/uploads/editor/15/qkpwk3d9czn8.png "")
          
                    }
                 }
              ],
         columns: [ { 
                         data: null,
                         defaultContent: '',
                     },        
                              
                    { className: 'detail-level-control',
                      orderable: false,
                      data: null,
                      defaultContent: '',
                      width: '5px'},
                    { data: "location_code", "visible": false }, 
                    { data: "machine_code", "visible": false }, 
                    { data: "doc_link", "visible": false }, 
                    { data: "task_number" },
                    { data: "scheduled_pm_number" },
                    { data: "last_pm_date" }, 
                    { data: "pm_scheduled" },
                    { data: "type_of_pm" },
                    { data: "next_pm_date" },
                    { data: "interval_to_next_pm" },
                    { data: "meter_reading" },
                    { data: "meter_scheduled_amount" }
                ],
         select: {
                    style: 'multi'
                 },

      } );

MultiColumn Ordering - LImit to only 2 columns at a time

$
0
0

Is there a way to limit the multi column ordering to only 2 columns at a time? On the client side, I want to allow users to sort up to 2 columns at a time.

Export to Excel is buggy

$
0
0

I am using the built in export to excel and the generated excel document is very buggy. The first two columns used for checkbox and expand icon show as 2 very wide empty columns. Any way to easily remove that?

The date columns are not sortable by excel. Formatting the cells does not help no matter what format of date I use.

Also we have a client matter number, which is 6 digits and then 5 digits separated by a period like 000001.00000.
This number is not displayed properly, formatting does not work for this either.

How to embed a child table into a column?

$
0
0

Hi all,

I need some help from you.

I would like to display details within a column. The data source is JSON likes beblow:

{
"OfferDetails": [
        {
            "OfferName": "Full Offer",
            "OfferStatus": "Available",
            "OfferType": "Primary",
            "Season": "Season 2020/2021",
            "Products": [
                {
                    "Name": "Car Pass - Full",
                    "MemberOfferProductID": "108906",
                    "ProductNumber": "P000310",
                    "Quantity": "1"
                },
                {
                    "Name": "Members Subscriptions - Full Members",
                    "MemberOfferProductID": "108904",
                    "ProductNumber": "P000158",
                    "Quantity": "1"
                },
                {
                    "Name": "Members Subscriptions - Full Members Guest",
                    "MemberOfferProductID": "108905",
                    "ProductNumber": "P000159",
                    "Quantity": "1"
                },
                {
                    "Name": "Full Member Joining Fees",
                    "MemberOfferProductID": "108907",
                    "ProductNumber": "P000665",
                    "Quantity": "1"
                }
            ]
        },
        {
            "OfferName": "Absentee Full Offer",
            "OfferStatus": "Available",
            "OfferType": "Alternate",
            "Season": "Season 2020/2021",
            "Products": [
                {
                    "Name": "Full Member Joining Fees",
                    "MemberOfferProductID": "108909",
                    "ProductNumber": "P000665",
                    "Quantity": "1"
                },
                {
                    "Name": "Annual Absentee Fee Full",
                    "MemberOfferProductID": "108908",
                    "ProductNumber": "P000326",
                    "Quantity": "1"
                }
            ]
        }
    ]

Any ideas to build a table like this:

Cheers

Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

Got two errors : Uncaught TypeError: Cannot set properties of undefined (setting '_DT_CellIndex')..

$
0
0

I got two errors:

  1. Uncaught TypeError: Cannot set properties of undefined (setting '_DT_CellIndex')
  2. main.js:54 Uncaught TypeError: Cannot read properties of undefined (reading 'toLowerCase')

and two questions:
1. When I click a menu the DataTable property is not working.
2. If you store your first data, you still need to refresh the page for the DataTable property will be working, but if you already refresh the page and store second data and or other data the dataTable is working.

my JS


<script > $(document).ready(function() { if ( $.fn.dataTable.isDataTable( '#permissionTable' ) ) { table = $('#permissionTable').DataTable(); } else { table = $('#permissionTable').DataTable( { paging: false } ); } } ); document.addEventListener("DOMContentLoaded", () => { $('#permissionTable').DataTable({ "pagingType": "full_numbers", stateSave: true }); Livewire.hook('element.updated', (el, component) => { $("#permissionTable").DataTable().destroy(); $('#permissionTable').DataTable({ responsive: true, paging : true, destroy : true, scrollY: 300, }); }) }); window.livewire.on('closePermissionModal', () => { $('#permissionModal').modal('hide'); var table = $('#permissionTable').DataTable({ responsive: true, paging : true, destroy : true, scrollY: 300, }); }); window.livewire.on('openPermissionModal', () => { $('#permissionModal').modal('show'); $("#permissionTable").DataTable().clear().destroy(); }); window.addEventListener('swal:confirmPermissionDelete', event => { swal.fire({ title: event.detail.title, text: event.detail.text, icon: event.detail.icon, showCancelButton: event.detail.showCancelButton, confirmButtonColor: event.detail.confirmButtonColor, cancelButtonColor: event.detail.cancelButtonColor, confirmButtonText: event.detail.confirmButtonText, }).then((result) => { if (result.isConfirmed) { window.livewire.emit('deletePermission',event.detail.id) swal.fire( 'Deleted!', 'Your file has been deleted.', 'success' ) } }); }); </script>

my html

<div>
    <div class="row">
        <div class="col-xs-12">
            <livewire:flash-message.flash-messages />
            <div class="panel">
                <div class="panel-heading">
                    <h3 class="panel-title">Permissions</h3>
                </div>

                <!--Data Table-->
                <!--===================================================-->
                <div class="panel-body">
                    <div class="pad-btm form-inline">
                        <div class="row">
                            <div class="col-sm-6 table-toolbar-left">
                                <button class="btn btn-purple" wire:click="createPermission"><i class="demo-pli-add icon-fw"></i>Add</button>
                                <!-- <button class="btn btn-default"><i class="demo-pli-printer icon-lg"></i></button> -->
                            </div>
                        </div>
                    </div>
                    <div wire:key="permissions" class="table-responsive">
                        <table id="permissionTable" class="table table-striped table-bordered table-hover table-fixed" cellspacing="0" width="100%"> 
                            <thead>
                                <tr>
                                    <th>Permission</th>
                                    <th>Actions</th>
                                </tr>
                            </thead>
                            <tbody>
                                @forelse ($permissions as $data)
                                <tr>
                                    <td>{{$data->name}}</td>
                                    <td class="text-center align-middle">
                                        <div class="btn-group">

                                            <button wire:click="editPermission({{ $data->id }})" class="btn btn-info delete-header m-1 btn-sm"  title="Edit"><i class="fa fa-pencil" aria-hidden="true"></i></button>

                                            <button wire:click="deleteConfirmPermission({{ $data->id }})" class="btn btn-danger delete-header m-1 btn-sm"  title="Delete"><i class="fa fa-trash-o" aria-hidden="true"></i></button>

                                        </div>                
                                    </td>
                                </tr>
                            
                                @empty
                                    <tr>
                                        <td style="text-align:center" colspan="2">No Record Found</td>
                                    </tr>
                                @endforelse   
                            </tbody>
                        </table>
                    </div>
                </div>
                <!--===================================================-->
                <!--End Data Table-->

            </div>
            <!-- The Modal -->
            <div wire.ignore.self class="modal fade" id="permissionModal" tabindex="-1" role="dialog" aria-labelledby="permissionModal" aria-hidden="true" data-backdrop="static" data-keyboard="false">
                <div class="modal-dialog" role="document">
                    <livewire:auth.permission-form />
                </div>
            </div>
        </div>
    </div>
</div>
@section('custom_script')
    @include('layouts.scripts.permission-scripts'); 
@endsection

Exclude Search Value from hidden dropdwon value

$
0
0

My project in .Net Core. I have a Grid which has editable inline row. That's why I bind the editable dropdown for that which is hidden. Now when I search something, the search result populate from that hidden dropdown list also which is not I want. So I want to ignore Search result from hidden dropdown value.
here is my html:
<td class="CompanyName">
<span>@item.CompanyName</span>
<select name="ddlcompany" id="ddlcompany" class="CompanyList" asp-for="@item.CompanyId" asp-items="@item.CompanyList" style="display:none">
</select>
</td>
<td class="BusinessUnitName">
<span>@item.BusinessUnitName</span>
<select name="ddlbusinessunit" id="ddlbusinessunit" class="BusinessUnitList" asp-for="@item.BusinessUnitId" asp-items="@item.BusinessUnitList" style="display:none">
</select>
</td>

Here is my Jquery:
$(document).ready(function () {
$("#DepartmentTable").DataTable({
"pageLength": 5,
"lengthMenu": [5, 10, 25, 50],
"order": []
});
})

Shortin Not Working After Inline Update Value

$
0
0

My project in .Net Core. I have a Grid which has editable inline row. First time when I short for Status Column its working fine.
But after inline edit if I update Status "Active" to "InActive" or vice versa then shorting not working properly.
The Html Code:
<td class="DepartmentStatus">
@if (@item.DepartmentStatus == "Active")
{
<span css="Status" id="status" name="status" class="active-td">@item.DepartmentStatus</span>
}
else
{
<span css="Status" id="status" name="status" class="inactive-td">@item.DepartmentStatus</span>

                }
                <select name="ddlstatus1" id="ddlstatus1" css="StatusList" asp-for="@item.DepartmentStatus" asp-items="@item.StatusList" style="display:none">
                </select>
            </td>

Here is my Jquery:
$(document).ready(function () {
$("#DepartmentTable").DataTable({
"pageLength": 5,
"lengthMenu": [5, 10, 25, 50],
"order": []
});
})

Putting shorting arrows next to button on responsive mode

$
0
0

Dear all,

Ideally, I would like to have something like this on responsive mode:

However, I'm getting this:

Which is only one sorting arrow, which belongs to the "Name" column sorting. So, how can I have several next to the button?

Another options that I would be happy to have instead:
1. Completely remove the sorting arrow on responsive view
2. To have only sorting arrow, but it should be set according to the current sorting. For example: if you press the "Position" button, then the down arrow should become blue; pressing it again, should activate the up arrow. The same if you press the other columns.

Here a test case:
https://jsfiddle.net/jmeile/vhjaz1o8/38/

Thanks in advanced

Best regards
Josef


Pagination not working when using post

$
0
0

Hello

I use datatable since a long time for a internal website. Due to proxy I had to change a request from get to post and impossible to have pagination working. It is working well when using type: "GET"

I need to use service side processing because the table has more than 80000 values

This is the code:

    var table = $('#inventory').DataTable( {
      "language": { "infoFiltered": "" },
     // "ajax": "server_processing.php?c=VMINVENTORY&t=<?php echo strtotime(date_format($dateLastInventory , 'F j, Y, g:i a')); ?>",
           "ajax": {
                    url:"server_processing.php?c=VMINVENTORY&t=<?php echo strtotime($check->getSelectedDate()); ?>",
                    type:"POST"
                     },
      "deferRender": true,
       "lengthMenu": [ [10, 25, 50, 100, -1], [10, 25, 50, 100, "All"] ],
      "search": {
        "smart": false,
        "regex": true
      },
       "dom": 'Blfrtip',
       "buttons": [
            'copy',
            'excel',
            'csv',
            'print'       
        ],
      "columnDefs": [
      { "targets": [ 0,  6, 7, 8, 9, 10, 11, 12,13, 15, 16, 17, 19,18,20,21,22,23,24,25,26], "visible": false } ,
      { "searchable": false, "targets": [ 21,22 ] }
      ],
        "processing": true,
      "fixedHeader": true,
      "serverSide": true,                                      

} );

Is there a know bug in datatables?

How to force a line break in header

$
0
0

I am using DataTables with Bootstrap4 and we would like to force a line break in the header, even though the column width does not require it.

For example: Vendor Name
It should display in the header as:

Vendor
Name

I have tried the usual suspects like :

Vendor<br>Name
Vendor Name
Vendor\nName

But noting works. The text is printed in the header as is, with all the tags and codes.

Is there a way to force the newline?

Thanks
Andre

export to PDF table width 100%

$
0
0

how to export to PDF and make table width 100%?

Updateing FixedColumns from 3.3.3 to 4.0.1 gives FixedColumns().update(): update is not a function

$
0
0

When I update FixedColumns form 3.3.3 to 4.0.1 or to 4.0.0 the function FixedColumns().update() does not exist anymore.
Going back to 3.3.3 and all works fine again.

codeline: table.fixedColumns().update();
Errormessage: Uncaught TypeError: table.fixedColumns(...).update is not a function

Is something changed in using update() in 4.0.1?

Inline one-to-many join editing

How to chang Info color ?

$
0
0

How can I change the color of the Info texts as highlighted in the image below :

My JS is as follows :
$(document).ready(function() {
var table = $('#example').dataTable({
"columnDefs": [
{ "targets": [3,4], "orderable": false }
]
});
} );

Show validation error message in cell, under value text, using inline editor

$
0
0

Hi,
I had a datatable (in Bootstrap 4 environment) with inline editor and everything works fine.

Now, I had to configure my datatable to execute validation in my inline editor, showing error message in the datatable, under the value of the cell.

I put this test code in presubmit event

        editor.on( 'preSubmit', function ( e, o, action ) {
            
            if (action == 'edit') { 
                var iniDateField = this.field( iniDate);
                iniDateField.error( 'Dummy error' );
                return false;
            }
        } );

but I dont see my custom message 'Dummy error' under the value of the cell,

How can I do this? How can I configure my datatable?

Thanks,

Davide


How to send parameter to language url

$
0
0

Guys, how to send parameter to** language: { url: ** . url is not visible in language

 var url = 'Not set';

    var emp = $('#countable')
        .on('init.dt', function () {

            let language = document.documentElement.lang;

            if (language === 'az') {
                url = '/plugins/datatables/i18n/az_AZ.json'
            } else if (language === 'ru') {
                url = '/plugins/datatables/i18n/ru_RU.json'
            }
        })

        .DataTable({
            language: {
                url: url,
                paginate: {
                    next: '»',
                    previous: '«'
                },
            },

chinese character can't be table column name.

$
0
0


Link to test case:
Debugger code (debug.datatables.net):
Error messages shown:
{"fieldErrors":[],"error":"An SQL error occurred: SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens","data":[],"ipOpts":[],"cancelled":[],"debug":[{"query":"SELECT ID as 'ID' FROM aaa WHERE ID = :where_0 ","bindings":[{"name":":where_0","value":"3","type":null}]},{"query":"UPDATE aaa SET Avatar = :Avatar, Name = :Name, \u5730\u5740 = :\u5730\u5740 WHERE ID = :where_0 ","bindings":[{"name":":Avatar","value":"68e1684d-0af7-44ab-8a5d-db72d26b95d08373945243958866952.jpg","type":null},{"name":":Name","value":"ddd","type":null},{"name":":\u5730\u5740","value":"gggg","type":null},{"name":":where_0","value":"3","type":null}]}]}
Description of problem:
I am newbee of the Editor, I have succesed make column dynamic, however, there is problem when my table's columns cotain chinese character, the problems were accounted in New insert and Edit.

Anyway, when I tried Editor table generator (as shown in pic) with chinese character column, it remind me "SQL column name: Not set"

It is running well when all columns are English character, May I know how to solve it?

Thanks.

$.fn.dataTable.Editor is not a constructor

$
0
0

I was trying to make editor working on my ruby on rails app using the trail package (JS + CSS) provided but Im gettng this error on my console.

--index.html.erb

<html>
<head>






<% render "include/datatablecss" %>

<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.11.3/css/jquery.dataTables.min.css"/>
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/buttons/2.0.1/css/buttons.dataTables.min.css"/>
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/select/1.3.3/css/select.dataTables.min.css"/>
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/datetime/1.1.1/css/dataTables.dateTime.min.css"/>
<% render "include/datatablesjava" %>

</head>

<%= notice %>

Students

<% @students.each do |student| %> <% end %>
First name Last name Age
<%= student.first_name %> <%= student.last_name %> <%= student.age %> <%= link_to 'Show', student %> <%= link_to 'Edit', edit_student_path(student) %> <%= link_to 'Destroy', student, method: :delete, data: { confirm: 'Are you sure?' } %>
$(document).ready(function (){ $('#example').DataTable() }) let editor; // use a global for the submit and return data rendering in the examples $(document).ready(function() { editor = new $.fn.dataTable.Editor( { ajax: "students/index", table: "#example", fields: [ { label: "First name:", name: "first_name" }, { label: "Last name:", name: "last_name" }, { label: "Age:", name: "age" } ] } ); // Activate an inline edit on click of a table cell $('#example').on( 'click', function (e) { editor.inline( this ); } ); $('#example').DataTable( { dom: "Bfrtip", ajax: "students/index", order: [[ 1, 'asc' ]], columns: [ { data: null, defaultContent: '', className: 'select-checkbox', orderable: false }, { data: "first_name" }, { data: "last_name" }, { data: "age" } ], select: { style: 'os', selector: 'td:first-child' }, buttons: [ { extend: "create", editor: editor }, { extend: "edit", editor: editor }, { extend: "remove", editor: editor } ] } ); } );

<br>

<%= link_to 'New Student', new_student_path %>
</html>

--include/datatablescss

@import "app/assets/stylesheets/css/editor.dataTables.css";

--include/datatablejava

--application.html.erb

<!DOCTYPE html>
<html>
<head>
<title>EditorTrial</title>
<meta name="viewport" content="width=device-width,initial-scale=1">
<%= csrf_meta_tags %>
<%= csp_meta_tag %>
<script src="https://code.jquery.com/jquery-3.6.0.js"></script>
<script src="https://code.jquery.com/ui/1.13.0/jquery-ui.js"></script>
<%= stylesheet_link_tag 'baggage', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>

<%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %>

</head>

<body>
<%= yield %>
</body>
</html>

--baggage.css

@import "css/editor.dataTables.css";
@import "css/editor.jqueryui.css";
@import "css/editor.foundation.css";
@import "css/editor.bootstrap.css";
@import "css/editor.bootstrap4.css";
@import "css/editor.bootstrap5.css";
@import "css/editor.bulma.css";
@import "css/editor.semanticui.css";

--application.js

import Rails from "@rails/ujs"
import Turbolinks from "turbolinks"
import * as ActiveStorage from "@rails/activestorage"
import "channels"

require("jquery")
require("bootstrap")
//require("/app/javascript/packs/editor.jqueryui")
//require("/app/javascript/packs/dataTables.editor.min")
require("/app/javascript/packs/dataTables.editor")

//require("/app/javascript/packs/editor.dataTables.min")

//require("/app/javascript/packs/editor.foundation")
//require("/app/javascript/packs/editor.bootstrap")
//require("/app/javascript/packs/editor.bootstrap4")
//require("/app/javascript/packs/editor.bootstrap5")
//require("/app/javascript/packs/editor.bulma")
//require("/app/javascript/packs/editor.semanticui")

let $ = require("jquery")
let dt = require("datatables.net");
let editor = require( "datatables.net-editor-server" );

$(document).ready(function (){
$('#details').DataTable()
})

Rails.start()
Turbolinks.start()
ActiveStorage.start()

Styling issue with bootstrap 4 and single button collection

$
0
0

Link to test case: http://live.datatables.net/ragopezo/1/edit
Debugger code (debug.datatables.net):
Error messages shown:
Description of problem: Hi DataTables team,
I found a small styling issue when using the colvis button as the only button with bootstrap 4 styling. The left border radius is missing. This seems to happen only with collections, a single 'copy' button doesn't have this issue.

The test case above is using the latest libraries from the download builder.

Greetings,
Itrac

Exporting (very) small numbers to Excel

$
0
0

Hi!

I have a datatable with very small numbers (e.g. 1.421532e-22) and when I use the Excel export button the numbers are not read by excel as numbers but as text. It is possible to use Excel's "Convert text to number" function once I have downloaded it but it decreases the user experience.

I want the Excel document to contain the same precision as my datatable which is why I cannot convert the number on my application to non-scientific before export.

I have tried to fix this in similar fashion as the forum posts that deal with very large number, however without any luck.

Viewing all 82252 articles
Browse latest View live


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