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

replicating Parent / child editing in child rows blog

$
0
0

Link to test case:
Debugger code (debug.datatables.net):
Error messages shown:
Description of problem:

I am trying to replicate the Parent / child editing in child rows blog on my server.

https://datatables.net/blog/2019-01-11

The section of the client file commented out results in an error when enabled i.e. uncommented.

    var siteTable = $("#sites").DataTable({
        dom: "Bfrtip",
        ajax: "../../Editor-PHP-1.9.4/controllers/sites.php",
        order: [1, "asc"],
        columns: [
/*          {
                className: "details-control",
                orderable: false,
                data: null,
                defaultContent: "",
                width: "10%"
            },
*/          
            { data: "name" },
            {
                data: "users",
                render: function(data) {
                    return data.length;
                }
            }
        ],

the error is as follows

jquery-3.3.1.js:3827 Uncaught TypeError: Cannot read property 'style' of undefined
    at Fa (jquery.dataTables.min.js:62)
    at ha (jquery.dataTables.min.js:48)
    at e (jquery.dataTables.min.js:93)
    at HTMLTableElement.<anonymous> (jquery.dataTables.min.js:93)
    at Function.each (jquery-3.3.1.js:354)
    at jQuery.fn.init.each (jquery-3.3.1.js:189)
    at jQuery.fn.init.n [as dataTable] (jquery.dataTables.min.js:83)
    at jQuery.fn.init.h.fn.DataTable (jquery.dataTables.min.js:165)
    at HTMLDocument.<anonymous> ((index):472)

I have created the client file as shown below, the server files are exactly as shown in blog users.php and sites.php.

I have added the CSS and pointed to my server

/* Paren Child CSS */
td.child-table {
    background-color: #bfdbff;
}
td.details-control {
    background: url('https://dividendlook.co.uk/Editor-PHP-1.9.4/examples/resources/details_open.png') no-repeat center center;
    cursor: pointer;
}
tr.shown td.details-control {
    background: url('https://dividendlook.co.uk/Editor-PHP-1.9.4/examples/resources/details_open.png') no-repeat center center;
}

Any help in this would be appreciated. I can provide access to my system via PM to investigate if required, with thanks.

To invoke the script

https://www.dividendlook.co.uk/testparentchilde/

PHP script below

https://www.dividendlook.co.uk/wp-admin/post.php?post=25438&action=edit

Best Regards

Colin

Client File below

<head>
<title>Sites Users</title>
<!-- 
https://editor.datatables.net/examples/advanced/parentChild
https://datatables.net/blog/2016-03-25
-->
<!-- Basic Datatables Editor Initilisation -->
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.19/css/jquery.dataTables.min.css" />
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/buttons/1.5.6/css/buttons.dataTables.min.css" />
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/select/1.3.0/css/select.dataTables.min.css" />
<link rel="stylesheet" type="text/css" href="https://www.dividendlook.co.uk/Editor-PHP-1.9.4/css/editor.dataTables.min.css" />
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.2/css/select2.min.css">

<!-- Basic Datatables Editor Initilisation -->
<script type="text/javascript"   src="https://code.jquery.com/jquery-3.3.1.js"></script>
<script type="text/javascript"   src="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js"></script>
<script type="text/javascript"   src="https://cdn.datatables.net/buttons/1.5.4/js/dataTables.buttons.min.js"></script>
<script type="text/javascript"   src="https://cdn.datatables.net/select/1.3.0/js/dataTables.select.min.js"></script>
<script type="text/javascript"   src="https://www.dividendlook.co.uk/Editor-PHP-1.9.4/js/dataTables.editor.js"></script>    
<script type="text/javascript"   src="https://cdn.datatables.net/responsive/2.2.3/js/dataTables.responsive.min.js"></script>
<script type="text/javascript"   src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.2/js/select2.min.js"></script> 

</head>

<table id="sites" class="display">
        <thead>
            <tr>
                <th>Name</th>
                <th>Users</th>
            </tr>
        </thead>
<tbody>     
<?php
global $wpdb;    
global $current_user;
get_currentuserinfo();
$user_id = $current_user->ID;
    
$rows = $wpdb->get_results("
SELECT 
sites.name AS site,
'1' AS users,
country.name AS country,
first_name AS firstname,
last_name AS lastname,
phone AS phone,
FROM
users
INNER JOIN sites ON (sites.id = users.site) 
INNER JOIN country ON (country.id = sites.country_id)
");
        
foreach ($rows as $row ){
    echo "<tr>";
    echo "<td>$row->site</td>";
    echo "<td>$row->users</td>";
    echo "</tr>";
}
?>
</tbody>
</table>

<table id="users" class="display">
        <thead>
            <tr>
                <th>First name</th>
                <th>Last name</th>
                <th>Phone #</th>
                <th>Location</th>
            </tr>
        </thead>
<tbody>     
<?php
global $wpdb;    
global $current_user;
get_currentuserinfo();
$user_id = $current_user->ID;
    
$rows = $wpdb->get_results("
SELECT 
sites.name AS site,
'1' AS users,
first_name AS firstname,
last_name AS lastname,
phone AS phone
FROM
users
INNER JOIN sites ON (sites.id = users.site) 
");
        
foreach ($rows as $row ){
    echo "<tr>";
    echo "<td>$row->firstname</td>";
    echo "<td>$row->lastname</td>";
    echo "<td>$row->phone</td>";
    echo "<td>$row->location</td>";
    echo "</tr>";
}
?>
</tbody>        
</table>

<input type='hidden' id='passuserid' value='<?php echo $current_user->ID; ?>'>
    
<script type="text/javascript">
(function($) {
var editor; // use a global for the submit and return data rendering in the examples
 
$(document).ready(function() {
function createChild(row) {
    var rowData = row.data();

    // This is the table we'll convert into a DataTable
    var table = $('<table class="display" width="100%"/>');

    // Display it the child row
    row.child(table).show();

    // Editor definition for the child table
    var usersEditor = new $.fn.dataTable.Editor({
        ajax: {
            url: "../../Editor-PHP-1.9.4/controllers/users.php",
            data: function(d) {
                d.site = rowData.id;
            }
        },
        table: table,
        fields: [
            {
                label: "First name:",
                name: "users.first_name"
            },
            {
                label: "Last name:",
                name: "users.last_name"
            },
            {
                label: "Phone #:",
                name: "users.phone"
            },
            {
                label: "Site:",
                name: "users.site",
                type: "select",
                placeholder: "Select a location",
                def: rowData.id
            }
        ]
    });

    // Child row DataTable configuration, always passes the parent row's id to server
    var usersTable = table.DataTable({
        dom: "Bfrtip",
        pageLength: 5,
        ajax: {
            url: "../../Editor-PHP-1.9.4/controllers/users.php",
            type: "post",
            data: function(d) {
                d.site = rowData.id;
            }
        },
        columns: [
            { title: "First name", data: "users.first_name" },
            { title: "Last name", data: "users.last_name" },
            { title: "Phone #", data: "users.phone" },
            { title: "Location", data: "sites.name" }
        ],
        select: true,
        buttons: [
            { extend: "create", editor: usersEditor },
            { extend: "edit", editor: usersEditor },
            { extend: "remove", editor: usersEditor }
        ]
    });

    // On change, update the content of the parent table's host row
    // This isn't particularly efficient as it requires the child row
    // to be regenerated once the main table has been reloaded. A
    // better method would be to query the data for the new user counts
    // and update each existing row, but that is beyond the scope of
    // this post.
    usersEditor.on( 'submitSuccess', function (e, json, data, action) {
        row.ajax.reload(function () {
            $(row.cell( row.id(true), 0 ).node()).click();
        });
    } );
}

function updateChild(row) {
    $("table", row.child())
        .DataTable()
        .ajax.reload();
}

function destroyChild(row) {
    // Remove and destroy the DataTable in the child row
    var table = $("table", row.child());
    table.detach();
    table.DataTable().destroy();

    // And then hide the row
    row.child.hide();
}
    
    
$(document).ready(function() {
    var siteEditor = new $.fn.dataTable.Editor({
        ajax: "../../Editor-PHP-1.9.4/controllers/sites.php",
        table: "#sites",
        fields: [
            {
                label: "Site name:",
                name: "name"
            }
        ]
    });

    var siteTable = $("#sites").DataTable({
        dom: "Bfrtip",
        ajax: "../../Editor-PHP-1.9.4/controllers/sites.php",
        order: [1, "asc"],
        columns: [
            {
                className: "details-control",
                orderable: false,
                data: null,
                defaultContent: "",
                width: "10%"
            },
//*/            
            { data: "name" },
            {
                data: "users",
                render: function(data) {
                    return data.length;
                }
            }
        ],
        select: {
            style: "os",
            selector: "td:not(:first-child)"
        },
        buttons: [
            { extend: "create", editor: siteEditor },
            { extend: "edit", editor: siteEditor },
            { extend: "remove", editor: siteEditor }
        ]
    });

    // Add event listener for opening and closing details
    $("#sites tbody").on("click", "td.details-control", function() {
        var tr = $(this).closest("tr");
        var row = siteTable.row(tr);

        if (row.child.isShown()) {
            // This row is already open - close it
            destroyChild(row);
            tr.removeClass("shown");
        } else {
            // Open this row
            createChild(row);
            tr.addClass("shown");
        }
    });

    // When updating a site label, we want to update the child table's site labels as well
    siteEditor.on("submitSuccess", function() {
        siteTable.rows().every(function() {
            if (this.child.isShown()) {
                updateChild(this);
            }
        });
    });
});

});
    
}(jQuery));</script>

43 child rows, on initial load it takes the responsive css a good few seconds to kick in

$
0
0

Each row has a lot of child rows (each row has 43+ columns). When the datatable initially loads, it takes a few good seconds before the table truncates the columns that are off to the right of the screen.

I want to keep all 43 columns, because I need to show the user all the values.
Is there anyway can speed up the load time, so the user doesn't see this screen.

Right now I can only think of showing a subset of the rows, and then when user clicks on a row, do an ajax call to get the rest of the data for the row, and populate that data in a modal. But I am trying to avoid this, as it seems like a lot of time will go into developing this.
Any other solutions or ideas would be greatly appreciated.

This is what the loading looks like, which I want to prevent.

After 2-3 seconds it properly formats.

Autofill does not work if filtered or searched

$
0
0

Editor 1.9.4
DataTables 1.10.21
Latest version of KeyTable and AutoFill

My code is pretty similar to this

Example of problem:
1. I click on drop down filter under "Assign To" column and select "User 1".
2. Then in the first row, I change "User 1" to "User 2" and then try use the AutoFill feature to drag across multiple rows.
3. AutoFill pops up a notification saying, "Fill in all cells with "User 1" rather than "User 2"
This problem also occurs if you search for the value in the search box and repeat steps 1 and 2. Is something I can add that fixes this?

Code below:

editor = new $.fn.dataTable.Editor({
        table: '#billingErrors',
        ajax: "tableServer-billingErrors.php",
        fields: [
        <?php 
        if(in_array("BILLINGERRORADMIN", $_SESSION['userRoles'])){
            echo "{
                label: 'Assigned To',
                name:  'assigned_to',
                type:  'select',
                options: [
                    { label: 'Empty',               value: '' },
                ]
            },";
        }
        ?>
            {
                label: "Note",
                name: "note",
                type: "textarea"
            },
            {
                label: "Completed",
                name: "completed",
                type: "select",
                options: [
                    { label: "Empty Status",    value: ""},
                    { label: "YES",             value: "YES"},
                    { label: "NO",              value: "NO"},
                    { label: "RETURN",          value: "RETURN"}
                ]
            }
        ]
    });

    tab = $("#billingErrors").DataTable({
        ajax: "tableServer-billingErrors.php",
        dom: 'Bfilrtilp',
        columns: [
            { data: "specnum_formatted" },
            { data: "patName" },
            { data: "valid_comment" },
            { data: "assigned_to" },
            { data: "completed" },
            { data: "client_name" },
            { data: "created_date" },
            { data: "accession_date" },
            { data: "client_code" },
            { data: "specclass_id" },
            { data: "note" }
        ],
        colReorder: true,
        searching: true,
        autoFill: {
            <?PHP 
                if(in_array("BILLINGERRORADMIN", $_SESSION['userRoles'])) 
                    echo "columns: ':nth-child(4),:nth-child(5),:nth-child(11)',"; 
                else 
                    echo "columns: ':nth-child(5),:nth-child(11)',"; 
            ?>
            editor:  editor
        },
        keys: {
            <?PHP 
                if(in_array("BILLINGERRORADMIN", $_SESSION['userRoles'])) 
                    echo "columns: ':nth-child(4),:nth-child(5),:nth-child(11)',"; 
                else 
                    echo "columns: ':nth-child(5),:nth-child(11)',"; 
            ?>
            editor:  editor
        },
        select: {
            style:    'os',
            selector: 'td:first-child',
            blurable: true
        },
        buttons: [
            {extend: "create", editor: editor }, 
            {extend: "edit",   editor: editor }, 
            'copy', 'csv', 'excel', 'pdf', 'print'
        ],
        initComplete: function(){
            tab.order([6,"desc"]);
            tab.draw();
            this.api().columns().every( function(){
                var column = this;
                var select = $('<select><option value=""></option></select>')
                    .appendTo( $(column.header()))
                    .on( 'change', function () {
                        var val = $.fn.dataTable.util.escapeRegex(
                            $(this).val()
                        );
                        column
                            .search( val ? '^'+val+'$' : '', true, false )
                            .draw();
                });
                column.data().unique().sort().each( function ( d, j ) {
                    select.append('<option value="'+d+'">'+d+'</option>' )
                });
                $('select', this.header()).click(function(event){
                    event.stopPropagation();
                });
            });
        },
        lengthMenu: [[10, 25, 50, -1], [10, 25, 50, "All"]],
        pageLength: -1
    });

BUG: Cannot use AUTOFILL on FIXED COLUMN

$
0
0

Link to test case:
Debugger code (debug.datatables.net):
Error messages shown:
Description of problem: It appears that you cannot autofill on columns that are fixed. Is this a known bug? Is there a fix being made for this issue?

How to add rows to Excel export or why are my Child Rows not exported?

$
0
0

I have a need to export Child Rows to Excel. I want them to be inserted below their parent row in Excel. Basically looking the same as the Child rows show in Datatables. Not sure this is the most efficient way but this solution fits my needs:
http://live.datatables.net/jeduxela/16/edit

I used the excelHtml5 customize function to insert the rows. Basically the function gets the sheetData which is all the rows that Datatables will export. It iterates through the rows inserting the additional child row(s) as it goes. The data to be inserted is part of the original Datatables row data.

This table:

Ends up as this spreadsheet:

Not much formatting, etc in the spreadsheet. More information about formatting can be found in the customize docs.

If anyone has a better way to do this please post an example or suggestions on how to improve.

Kevin

disable inline editing on specific columns with ajax

$
0
0

I am new with ajax, and I cannot figure out how to disable inline editing on column 0 and 2 on my datatable, can anyone help?

thanks

$(document).ready(function(){
  
  fetch_data();

//fetch record from inventory
  function fetch_data()
  {
   var dataTable = $('#sample_data').DataTable({
    "processing" : true,
    "serverSide" : true,
    "order" : [],
    "ajax" : {
     url:"AddInventoryFetch.php",
     type:"POST"   
    },
    "columnDefs":[
    {
      "targets":[0, 2],
      "orderable":false,
    },
    ]
   });
  }
});

How to regain focus control after keytable blurable:false

$
0
0

I have a form which pops up a bootstrap modal containing a datatable with keytable so that cells can be selected visually with arrow keys or mouse click. The requirement of how to select an item to return to the calling form is to press a "Done" button next to the table which extracts the data from the cell that has focus, closes the modal, and inserts the data value into the appropriate form field. My initial problem was that when the "Done" button was clicked, the table cell that was selected lost focus returning "undefined" when trying to get the value of the focused cell. I found the blurable:false option which keeps focus on the table so that the button can extract the data now. This all works.

However, once the modal with the datatable is closed and I am back in the main form, I found I was unable to tab to the next field. Reading about the blurable option:

his ability to loose focus (blurring) can be disabled in KeyTable by setting this option to false. That means that once the table has been focused (which it can be automatically using keys.focus) focus cannot be removed (although interaction can be disabled using keys.disable()).

So, once I close the modal, I also do this:
table.keys.disable();
This does not seem to have any effect. Reading the description if the disable() function:

Disable KeyTable. Please note that this disallows future interactions with the table (until re-enabled), but does not cause the table to blur (i.e. loose focus). If a cell has focus, that focus will be retained after this method has been called.

So, despite what it says on the blurable page, if I understand correctly, the keys.disable() function does not remove the focus hold on the table.

Question: How do I restore the ability to give other elements in the page focus once I close the modal that contained the table (I do not need it at all anymore and if opened again, it can be re-initialized).

Cannot see navigational properties for FK

$
0
0

Hi,

I am using DataTables to display the Registrations. Everything worked fine before when I was using the table Microsoft used in their tutorial. This also stops me from Editing the registration and displaying it in Details mode. So I want to display the names of each navigational property object. I know I can install Editor libraries and use Left Join but that's like over $100 dollars. Is there another way? I'm just a student after all.

I have got the files to help replicate the problem including the Registration\Index.cshtml file.

Expected behavior:

It renders the two other navigational properties "User" and "Job".

Actual behavior:

It only displays the RegistrationDate field. And if I select Edit or Details or Delete It crashes saying "No web page was found for the web address."

Environment data
.NET Core SDK (reflecting any global.json):
Version: 2.2
Runtime Environment:
OS Name: Windows
OS Version: 10.0.18363
OS Platform: Windows
RID: win10-x64


Datatables error on editor error from server.

$
0
0

I am using Editor with inline edit with the help of KeyTable. It is working well in case of success from the server, but in case of error, I get error in js, picture is attached.

and Everything stop working after this.

My code for the keyTable is: keys: { columns: notEditableColumns, keys: [9], editor: editor, editOnFocus: true }, select: { style: 'os', selector: 'td:first-child' },

Send email on row edit with editor

$
0
0

Im trying to get an email to fire off when an edit is made.


include( "lib/DataTables.php" ); use DataTables\Editor, DataTables\Editor\Field, DataTables\Editor\Format, DataTables\Editor\Mjoin, DataTables\Editor\Options, DataTables\Editor\Upload, DataTables\Editor\Validate, DataTables\Editor\ValidateOptions; Editor::inst( $db, 'rma_submissions', 'ID' ) ->fields( Field::inst( 'rma_submissions.id' ), Field::inst( 'rma_submissions.timestamp' ) ->validator( Validate::dateFormat( 'Y-m-d H:i:s' ) ) ->getFormatter( Format::datetime( 'Y-m-d H:i:s', 'Y-m-d H:i:s' ) ) ->setFormatter( Format::datetime( 'Y-m-d H:i:s', 'Y-m-d H:i:s' ) ), Field::inst( 'rma_submissions.location' ), Field::inst( 'rma_submissions.orig_invoice' ), Field::inst( 'rma_submissions.all_accessories' ), Field::inst( 'rma_submissions.new_submission' ), Field::inst( 'rma_submissions.man_sku' ), Field::inst( 'rma_submissions.device_id' ), Field::inst( 'rma_submissions.failure_desc' ), Field::inst( 'rma_submissions.defective_oob' ), Field::inst( 'rma_submissions.original_sales_date' ), Field::inst( 'rma_submissions.vendor' ), Field::inst( 'rma_submissions.email' ), Field::inst( 'rma_submissions.device_man' ), Field::inst( 'rma_submissions.district' ), Field::inst( 'rma_submissions.rma_number' ), Field::inst( 'rma_submissions.paid' ), Field::inst( 'rma_submissions.paid_date' ), Field::inst( 'rma_reasons.reason_description' ), ) ->on( 'postEdit', function ( $editor, $id, $values, $row ) { }) ->leftJoin( 'rma_reasons', 'rma_reasons.reason_code', '=', 'rma_submissions.failure_desc' ) ->on( 'postEdit', function ( $editor, $id, $values, $row ) { $to = "sku@mysite.net"; $subject = "rmaUpdate Completed"; $message = " <html> <head> <title>rmaUpdate Complete</title> </head> <body> <p>This is a copy of your rma Update Request</p> <table> <tr><td>Email: <b> $row['email']</b></td></tr> <tr><td>Notes: <b> $row['failure_desc']</b></td></tr> <tr><td>RQ Sku: <b> $row['man_sku']</b></td></tr> <tr><td>Completed?: <b> Yes </b></td></tr> </table> </body> </html> "; // Always set content-type when sending HTML email $headers = "MIME-Version: 1.0" . "\r\n"; $headers .= "Content-type:text/html;charset=UTF-8" . "\r\n"; // More headers $headers .= 'From: <support@mysite.net>' . "\r\n"; $headers .= 'cc: <'.$row['email'].'>' . "\r\n"; mail($to,$subject,$message,$headers); } ) ->process( $_POST ) ->json();

The above saves the data but gives me an error with my editor.

Any suggestions?

Editor: Editing a single row updates multiple rows on the server, reload multiple rows

$
0
0

Hi,
I need to know whether this is possible:

I have data in my Editor, and when a user updates a specific column (field), it causes updates to multiple rows and fields on the server. The server should then return an array of the new data for the rows that were updated.

However, at the moment, my understanding is that the Editor expects data for only 1 row back. So I have an issue, where it just replaces the 1 row that was initially updated with the first returned data object, even though an array is returned. Is it possible for the Editor to handle multiple rows returned after single row update and updating them locally based on their ID ? Or do I just have to reload the entire table after each edit ?

Hope that makes sense.

Add one more parameter when running ajax

$
0
0

Good morning I have the following problem in the ajax url I use the following,

ajax: {
url: 'http://api/example',
data: {size: 1000},
dataSrc: 'data'
},

but when it is executed, it adds a parameter that I do not put and in the network I get this

http://api/example?size=1000&_=1596784035094

and therefore it is not bringing me the data by that parameter that is added. How can I remove it?

How can I dynamically add a row that contains HTML elements?

$
0
0

Hello,

I'm adding a new entry to my database with AJAX and then adding it to the datatable like this:

let href = $('<a href="/an/amazing/url" class="btn btn-light-danger"><i class="bx bx-trash"></i>'<span>Delete</span></a>');
$(table).DataTable().row.add([
data.id,
data.name
href
]).draw();

The row is added successfully.
My problem is with the "href" element. Instead of rendering as an HTML element, only the URL is displayed in plain text. How can I rend the whole "href" as HTML?

Server side validation with dependent editor fields

$
0
0

Hi Allan, further to this question https://datatables.net/forums/discussion/63624/apply-validation-to-many-fields I am also using dependent fields in my form for example in the code below I have the fields 'importtest.CurrentMarriageSpouseFamilyName' and 'importtest.PreviousMarriageSpouseFamilyName'.

->on( 'preEdit', function ( $editor, $id, $values ) {

        if ( $values['importtest']['task_status'] > '3') {
 
    $fieldNames = ['importtest.FamilyName', 'importtest.FamilyNameAtBirth', 'importtest.CurrentMarriageSpouseFamilyName', 'importtest.PreviousMarriageSpouseFamilyName' ];
 
     for ( $i=0; $i<count($fieldNames); $i++) {
     $editor->field($fieldNames[$i])

      //not empty
              ->validator( Validate::notEmpty( ValidateOptions::inst()
                ->message( 'A Family name is required' )
               ) )
             //not more that 70 characters
            ->validator( function ( $val, $data, $field, $host ) {
               return strlen( $val ) > 70 ?
            'Family name length must be 70 characters or less' :
            true; 
             } )
            //no numbers, lowercase 
            ->validator( function ( $val, $data, $field, $host ) {
               return preg_match('/^(([A-Z\'][A-Z \' -]*[A-Z\'])|([A-Z\']+))$/', $val) < 1 ?
            'Family name must not contain numbers, must be in capital letters, and can only accept apostrophies, dashes, and spaces' :
            true; 
             } );
}

Of course the 'importtest.PreviousMarriageSpouseFamilyName' field is only required if a previous marriage occurred so I am using editors dependent field option in the form to hide it unless a drop down field value equals the required value to show it.

 editor.dependent( [ 'importtest.NumberOfAdditionalMarriages'], function ( val ) {
      
       if  (editor.field('importtest.NumberOfAdditionalMarriages').val() == '1')

        {
          editor.field ('importtest.PreviousMarriageSpouseFamilyName').show();
         
        }
             return {};
   } );

When the 'importtest.PreviousMarriageSpouseFamilyName' field is hidden in editor it will still trigger the validation error which I understand is normal. I could include an aditonal if statement on the PreEdit function to detect if the dependent field is required or not, but I'm just wondering if there is a better way to do this?

Autofill does not work if the query where condition is triggered

$
0
0

Link to test case:
Debugger code (debug.datatables.net):
Error messages shown:
Description of problem:
I have editor 1.9.4, datatables 1.10.21, the latest keyTable, AutoFill according the debugger both are enable and work fine for the most part.

The issue I'm having is when a user selects "YES" from a drop down option for a column named "Completed" and then tries to drag this down several column rows to perfom the Autofill, it doesn't execute. It's related to my query from the "Tableserver.php" in which I have a where clause that searches for records where "Completed" != "YES". If I disabled that line of for the query, then the AutoFill works just fine.

Is there a way to have the AutoFill still fill in multiple column rows on a filter query?


deleted uploaded files still uploads

$
0
0

Hello,

We have setup dataTables and Editor and appear to be working fine as in populating tables, making edits and uploading files. It has been setup to allow multi-files upload and this is working fine as well.

However, when a file or files are selected to be uploaded, then we click the X button to cancel the file upload, or in other wards, decided we no longer wish to upload the file we just selected, so we click the X, the file is gone from the upload screen, however when clicking the update button, the file/files are still getting upload or recorded into the database.

Would this be a bug or am I missing some configuration?

Part of the editor initialization below:
{
label: "Documentation:",
name: fileField,
type: "uploadMany",
display: function (file_id) {
var file = editor.file('files', file_id);
var fileName = file.fileName.substring(file.fileName.lastIndexOf('\') + 1);
return '<a href="' + file.web_path + '" download="' + fileName + '">' + fileName +'</a>';},

Version of Editor is: 1.9.0

Version of dataTable below:

src="https://cdn.datatables.net/buttons/1.5.6/js/dataTables.buttons.min.js"
src="https://cdn.datatables.net/select/1.3.0/js/dataTables.select.min.js"
src="https://cdn.datatables.net/buttons/1.5.6/js/buttons.colVis.min.js"
src="https://cdn.datatables.net/buttons/1.5.6/js/buttons.html5.min.js"
src="https://cdn.datatables.net/buttons/1.5.6/js/buttons.print.min.js"
src="~/js/libs/dataTables.checkboxes.min.js"
src="~/js/libs/dataTables.editor.min.js"

Thanks

how to remake the search for a date?

RowReorder

$
0
0

Please help me how i can add RowReorder in the following code

var grid = new Datatable();
grid.init({
src: $("#datatable_site"),
onSuccess: function(grid) {
// execute some code after table records loaded
},
onError: function(grid) {
// execute some code on network or other general error
},
dataTable: {
"aLengthMenu": [
[20, 50, 100, 150, 200],
[20, 50, 100, 150, 200] // change per page values here
],

            "iDisplayLength": 20, // default record count per page
            "bServerSide": true, // server side processing
            "sAjaxSource": BASE_URL +"/admin/successStoryList", // ajax source

            "aaSorting": [[1, "asc"]
            ], // set first column as a default sort by asc
            "fnServerParams": function(aoData) {
                aoData.push({
                    "name": "sAction",
                    "value": 'filter'
                });
                aoData.push({
                    "name": "_token",
                    "value": $('#_token').val()
                });
                aoData.push({
                    "name": "mem_username",
                    "value": $('#mem_username').val()
                });
                aoData.push({
                    "name": "status",
                    "value": $('#status').val()
                });
                aoData.push({
                    name: "sGroupActionName",
                    value: sGroupActionName
                });
                aoData.push({
                    name: "id[]",
                    value: id
                });
                aoData.push({
                    name: "key",
                    value: $('#_key').val()
                });
                aoData.push({
                    name: "val",
                    value: $('#_val').val()
                });

            },
            "aoColumns": [
              {
                  "bSearchable": false,
                  "bSortable": false
              },
              {
                    "bSearchable": false,
                    "bSortable": false
                },
                {
                    "bSearchable": false,
                    "bSortable": false
                },
                {
                    "bSearchable": false,
                    "bSortable": true
                },
                {
                    "bSearchable": false,
                    "bSortable": true
                },
                {
                    "bSearchable": false,
                    "bSortable": true
                },
                {
                    "bSearchable": false,
                    "bSortable": true
                },
                {
                    "bSearchable": false,
                    "bSortable": true
                },
                {
                    "bSearchable": false,
                    "bSortable": true
                },
                {
                    "bSearchable": false,
                    "bSortable": true
                },

            ]
        }
    });

How to set fix header for datatables library in symfony projevt with webpack

$
0
0

I use Symfony with webpack and faced with problem when add new packeg datatables. I read many post about problem exclude this library and only one way give me successful resul wihout error by import

package.json

{
  "devDependencies": {
    "@fortawesome/fontawesome-free": "^5.8.2",
    "@symfony/webpack-encore": "^0.30.0",
    "bootstrap": "^4.3.1",
    "core-js": "^3.0.0",
    "node-sass": "^4.12.0",
    "popper.js": "^1.15.0",
    "regenerator-runtime": "^0.13.2",
    "sass-loader": "^8.0.0",
    "webpack-notifier": "^1.6.0"
  },
  "license": "UNLICENSED",
  "private": true,
  "scripts": {
    "dev-server": "encore dev-server",
    "dev": "encore dev",
    "watch": "encore dev --watch",
    "build": "encore production --progress"
  },
  "dependencies": {
    "datatables.net": "^1.10.21",
    "datatables.net-autofill-bs4": "^2.3.5",
    "datatables.net-bs4": "^1.10.21",
    "datatables.net-buttons-bs4": "^1.6.3",
    "datatables.net-colreorder-bs4": "^1.5.2",
    "datatables.net-dt": "^1.10.21",
    "datatables.net-fixedcolumns-bs4": "^3.3.1",
    "datatables.net-fixedheader-bs4": "^3.1.7",
    "datatables.net-keytable-bs4": "^2.5.2",
    "datatables.net-responsive-bs4": "^2.2.5",
    "datatables.net-rowgroup-bs4": "^1.1.2",
    "datatables.net-rowreorder-bs4": "^1.2.7",
    "datatables.net-scroller-bs4": "^2.0.2",
    "datatables.net-searchpanes-bs4": "^1.1.1",
    "datatables.net-select-bs4": "^1.3.1",
    "file-loader": "^3.0.1",
    "jquery": "^3.4.1",
    "url-loader": "^1.1.2"
  }
}

app.js

import '../css/app.scss';
import * as dt_bs4 from 'datatables.net-bs4'
import * as fh_bs from 'datatables.net-fixedheader-bs4';

require('@fortawesome/fontawesome-free/css/all.min.css');
require('datatables.net-dt/css/jquery.dataTables.min.css');
require('@fortawesome/fontawesome-free/js/all.js');

const $  = require( 'jquery' );
global.$ = global.jQuery = $;
require('bootstrap');

when I try followed to documentation

var $ = require( 'jquery' );
require( 'datatables.net-bs4' )( window, $ );
require( 'datatables.net-fixedheader-bs4' )( window, $ );

I faced with error TypeError: Cannot set property '$' of undefined

my_file.js

import list from './parts/sort.js';

document.addEventListener("DOMContentLoaded", function () {
    list();
});

sort.js

export default function list() {

    $('#example').dataTable({
        fixedHeader: true
    });   
}

how to correct exclude this library? And my main goeal for today enable opportunity fix header

Bonjour,

$
0
0

Link to test case:
Debugger code (debug.datatables.net):
Error messages shown:
Description of problem:

Viewing all 82208 articles
Browse latest View live


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