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

Height resizing of edit form not correct when using dependent()

$
0
0

When using the dependent() option with a lot of fields, the automatic height resizing of the edit form is not working properly, so the Update button is not at the bottom of the edit form any more but moves upwards overlapping the input fields area.
This only happens when while dependent fields showing there is a scrollbar due to the large number of fields and while dependent fields being hidden there are only a few fields left without scrollbar.
Is there any way to trigger the resizing after the dependent() routine has fired to adjust the form height properly? Or as an alternative to set a fixed form height which can handle both shown and hidden dependent fields?

Thanks, Denis


Editor Validation - Accept only dbValues available in another column

$
0
0

How exactly can I define that for 'column_04' (text input) only values available in column_02 (of the database column) ... or empty ('') are valid? Like this?

Editor::inst( $db, 'users' )
    ->field(
        Field::inst( 'users.column_01' ),
        Field::inst( 'users.column_02' ),
        Field::inst( 'users.column_03' ),
        Field::inst( 'users.column_04' )
            ->validator( 'Validate::dbValues', array(
                'field' => 'users.column_02'
                'valid' => array(''),
                'message' => "Value does not exist!"
            ) )
    )
    ->process($_POST)
    ->json();

I'm not exactly sure https://editor.datatables.net/manual/php/validation

System Error on Ajax Response

$
0
0

Hi,

I’m a licenced user and have been implementing DataTables and Editor for an internal project. I’ve prechecked the documentation / forums and can’t get my head around this issue.

I have a Editable datatable, which is loading JSON data successfully from the server.

JSON from server:

{
"data": [
{
"DT_RowId": "row_3",
"FUND_MANAGER": "Graham K4-D15 (Innocap Track)",
"NO_MULTI_MGR_OR_PORT_ALPHA": "ABC",
"PERCENT_SUBINVESTMENT_GRADE": "DEF",
"BENCHMARK_DRIVEN": "",
"MINIMU_SIZE": "",
"UCITS_III": "",
"TOTAL_ASSETS_FUND": "",
"SCORE": "",
"COMMENT": ""},
{
"DT_RowId": "row_1",
"FUND_MANAGER": "SPDR Gold Tracker",
"NO_MULTI_MGR_OR_PORT_ALPHA": "",
"PERCENT_SUBINVESTMENT_GRADE": "",
"BENCHMARK_DRIVEN": "",
"MINIMU_SIZE": "",
"UCITS_III": "",
"TOTAL_ASSETS_FUND": "",
"SCORE": "",
"COMMENT": ""},
{
"DT_RowId": "row_2",
"FUND_MANAGER": "Transtrend (Innocap Track)",
"NO_MULTI_MGR_OR_PORT_ALPHA": "",
"PERCENT_SUBINVESTMENT_GRADE": "",
"BENCHMARK_DRIVEN": "",
"MINIMU_SIZE": "",
"UCITS_III": "",
"TOTAL_ASSETS_FUND": "",
"SCORE": "",
"COMMENT": ""}
],
"options": [],
"files": []
}

On inline editing a cell value and then clicking out, the AJAX request is sent and the server returns the expected JSON but the rows are not being updated. Instead, I get an error message: ‘A system error has occurred (More information)’ under the field taking me to: https://datatables.net/manual/tech-notes/12.

JSON returned:
Have tried returning the above JSON (using the same URL for param ajax: under editor), as well as the following:

{
   "data":    [
        {
            "DT_RowId": "row_3",
            "FUND_MANAGER": "Graham K4-D15 (Innocap Track)",
            "NO_MULTI_MGR_OR_PORT_ALPHA": "ABC",
            "PERCENT_SUBINVESTMENT_GRADE": "DEF",
            "BENCHMARK_DRIVEN": "GEF",
            "MINIMU_SIZE": "",
            "UCITS_III": "",
            "TOTAL_ASSETS_FUND": "",
            "SCORE": "",
            "COMMENT": ""
        }
    ]
}
  • I have extracted the HTML and javascript from our page and can be viewed here: https://jsfiddle.net/zsaeed/39brvysm/4/#
  • This being an internal application is not accessible outside the site.
  • The response headers shown by the browser are correct too:
    Content-type: application/json
  • A thought, could it be a version issue with Jquery?

Kind regards

DataTables Editor - can the edit form be a full page and scrollable

$
0
0

I know I can do inline editing and bubble editing with the Editor, but my data for a row requires a number of fields to be created/edited..

My current implementation for editing an item is a separate web page that is scrollable so all fields can be seen and edited.

Is this possible with DataTables Editor and, if so, is there an example?

Regards,
Jim

how to submit selected orders on both pages at the same time without changing the show entries

$
0
0

i used this line
table.rows().nodes().page.len(-1).draw(); it erasing show entries .for example before submit i selected 10 after submit it showing all rows. i need to preserve the state of Show entries while submitting form with all pages selected rows.

Purchase of Editor

$
0
0

I am planning to purchase Editor but am not quite sure how to apply the license to the downloaded files.

Currently I download a bespoke zip file which includes all the components I need using the DataTables download page.

Once I purchase the license I will download another such zip file that includes Editor and replace what I have.

How is the license activated?

Regards,
Jim

Datatables within a bootstrap 3 tab

$
0
0

I have a page with three bootstrap tabs. Only the second tab includes a datatable. However, when I click to show the tab the datatable isn't redrawing so columns are squished and the table only takes up part of the page. I've followed docs at https://datatables.net/examples/api/tabs_and_scrolling.html to tell the datatable to recalc but nothing happens. Datatables version is 1.10.12. Any help is appreciated!

<html>
<head>
    <link media="all" type="text/css" rel="stylesheet" href="dataTables.bootstrap.min.css">
</head>
<body>

<!-- ... -->

<div role="tabpanel" class="tab-pane mt-30 active" id="participants">
<div class="box-body">
    <div class="table-responsive">
        <table id="participants-table" class="table table-condensed table-hover">
            <thead>
            <tr>
                <th>Org ID</th>
                <th>First Name</th>
                <th>Last Name</th>
                <th>Email</th>
                <th>Group</th>
                <th>Referral Code</th>
                <th>Actions</th>
            </tr>
            </thead>
        </table>
    </div><!--table-responsive-->
</div><!-- /.box-body -->
</div><!--tab participants-->

<!-- ... -->

<script src="jquery.js"></script>
<script src="jquery.dataTables.min.js"></script>
<script src="dataTables.bootstrap.min.js"></script>


    <script>
        $(document).ready(function() {
            $('a[data-toggle="tab"]').on( 'shown.bs.tab', function (e) {
                if(e.currentTarget.hash == '#participants') {
                    $('.tab-content > #participants').show();
                    $.fn.dataTable.tables( {visible: true, api: true} ).columns.adjust();
                } else {
                    $('.tab-content > #participants').hide();
                }
            } );

            $('#participants-table').DataTable({
                processing: true,
                serverSide: true,
                ajax: {
                    url: 'participant/get',
                    type: 'post'
                },
                columns: [
                    {data: 'org_internal_id', name: 'participants.org_internal_id'},
                    {data: 'first_name', name: 'participants.first_name', render: $.fn.dataTable.render.text()},
                    {data: 'last_name', name: 'participants.last_name', render: $.fn.dataTable.render.text()},
                    {data: 'email', name: 'participants.email', render: $.fn.dataTable.render.text()},
                    {data: 'org_group', name: 'participants.org_group', searchable: false, render: $.fn.dataTable.render.text()},
                    {data: 'referral_code', name: 'participants.referral_code', sortable: false, render: $.fn.dataTable.render.text()},
                    {data: 'actions', name: 'actions', searchable: false, sortable: false}
                ],
                order: [[0, "asc"]],
                searchDelay: 500
            });
        });
    </script>
</body>
</html>

Edit columns header exporting to excel

$
0
0

Hi all,

i'm using buttons extension to export to excel (excelHtml5), and I want to know if its posible to rename all columns header as I like.

Thanks in advance.


How to Save Full row Data using Save button in Last Cell

$
0
0

Hi,
How can i save full row data using save button in Last Cell.

Regards.
Sunil

Map Enter to Tab

$
0
0

Hi All,
How to map Enter to Tab in DataTable Editor.

Regards.
Sunil

dataTables not initializing?

value breaks in Filter Dropdown in ColumnFlterWidget jQuery Datatable Plugin

$
0
0

I am using a jQuery ColumnFilterWidget.js plugin in my Angular Datatable. I am facing an issue with one of the Filter widget where I want to filter Company name. For example, I have a company name in my datatable "Company/USA" but in dropdown filter I see two values: "Company" & "USA" and selecting any one of them filters the data.

When use Export Buttons the Pagesize drop down disappears.

Exporting all rows to CSV, instead of what is just displayed on page.

$
0
0

Here is the code. Works great except the export will not export all. Note: It uses server side, so i am probably missing something.

$(document).ready(function() {
    $('#users').DataTable( {
        "processing": true,
        "serverSide": true,
        "dom": 'Blfrtip',
        'pageLength':10,
        "buttons": [
            {
                extend: 'csv',
                text : 'Export to CSV',
                exportOptions : {
                    modifier : {
                        // DataTables core
                        order : 'current',  // 'current', 'applied', 'index',  'original'
                        page : 'all',      // 'all',     'current'
                        search : 'applied'     // 'none',    'applied', 'removed'
                    }
                }
            }
        ],
        "ajax": {
            "url":      "cgi-bin/businessview.pl",
            "dataType": "json",
            "data": function ( d ) {
                x=2;
            },
            "dataSrc": function ( json ) {
              for ( var i=0, ien=json.data.length ; i<ien ; i++ ) {
                json.data[i][0] = '<a href=#>'+json.data[i][0]+'</a>';
              }
              return json.data;
            }
            // Never use success with Datatables, instead use dataSrc
            // "success": function(json){
            //     return json;
            // }

         }
    } );
});

Support for parent-child-grandchild tables

$
0
0

I have an application requirement to display three-levels of hierarchy. The examples show only parent-child.

This question was asked and answered No back in July 2015 (https://datatables.net/forums/discussion/28700). I could not find mention of this feature in the release notes since. Does anyone know if support has been added? Has anyone found a solution or work-around?

Thanks,
John


Field.setValue based on the value of other fields.

$
0
0

I want to set the name field's value based on the value of fields last_name and first_name. I have tried the source field's getValue function but I receive a call to undefined function fatal error. The Editor documentation lists getValue as an existing function, and the method exists in Field.php, for a field instance. Clearly, I am doing something incorrectly. What am I missing?

Field::inst( 'name' )
                ->set( Field::SET_BOTH ) // Do this for create and edit.
                ->setValue(Field::inst( 'last_name' ).getValue()),

datatables shows up with funny version in npm outdated

$
0
0

Hi, I am wondering why npm outdated shows a version 3.2.2. Isn't 1.10.13 the latest version of the core datatables?

Package                          Current   Wanted            Latest
datatables.net                   1.10.13  1.10.13             3.2.2
datatables.net-bs                1.10.13  1.10.13             3.2.2

Editor (2)

$
0
0

I seem to have run into another wrinkle with the behaviour of the editor. I believe it is related to my previous post titled 'Editor'.

The problems is:
When using the bubble edit functionality I start at the first row(1) and the edit is properly recorded. The second row(2) also behaves as expected. If I then leave a gap after the second row(2) edit and edit another row(5) it behaves as expected. Now when I return to row(1) or any previously edited row the last edit I made(row 5) is presented in the edit dialogue and if I change it the last row(5) I edited is updated. If I then edit a row that has never been edited it works as expected in that the dialogue is presented with the cell data. The behaviour is the same when I use a checkbox, and an edit button and do the editing through a form.
When it misbehaves the data content that gets passed into the function is from the last edited console.log("the row ",t.row( this ).data()); while the row index console.log("the row ",t.row( this ).index()); is correct and does not match the data.

The site is still available at

https://tmtest.dlinkddns.com:10010
Sign In with
user - datatables
password - 1234

The Editor Definition

   editor = new $.fn.dataTable.Editor( {
        table: "#myTable",
        fields: [
            {type: "readonly", label: "depotName", name: "depotName" } ,
            {type: "readonly",label: "clientName", name: "clientName"},
            {type: "readonly",label: "rtuName", name: "rtuName"},
            {type: "readonly",label: "deviceName", name: "deviceName"},
            {type: "readonly",label: "serialNumber", name: "serialNumber"},
            {type: "readonly",label: "assetNumber", name: "assetNumber" },
            {label: "serviceTag", name: "serviceTag"},
            {type: "readonly",label: "location", name: "location" },
            {type: "readonly",label: "ipAddress", name: "ipAddress"},
            {type: "readonly",label: "deviceType", name: "deviceType"},
            {type: "readonly",label: "deviceStatusMessage", name: "deviceStatusMessage" },
            {type: "select", label: "quiesce", name: "quiesce", options: quiesceOpts },
            {type: "readonly",label: "utilization", name: "utilization" },
            {type: "readonly",label: "coverage", name: "coverage"},
            {type: "readonly",label: "monoLifeCount", name: "monoLifeCount" },
            {type: "readonly",label: "colorLifeCount", name: "colorLifeCount"},
            {type: "readonly",label: "pageCountThisMonth", name: "pageCountThisMonth"},
            {type: "readonly",label: "createdDate", name: "createdDate"},
            {type: "readonly",label: "lastActiveDate", name: "lastActiveDate" },
            {type: "readonly",label: "deviceId", name: "deviceId"}
        ],
        ajax: function ( method, url, d, successCallback, errorCallback ) {
            var output = { data: [] };
            if ( d.action === 'edit' ) {
                  // Update each edited item with the data submitted
                $.each( d.data, function (id, value) {
                   //console.log(findIndexInData(theTable.data, 'deviceId', id));
                   console.log("in edit -id ",id," -value ",value);
                   value.DT_RowId = id;
                   $.extend( todo, value );
                   console.log("todo after extend ",todo);
                   console.log("output before push ",output);
                   output.data.push( todo );
                } );
            }
             // Store the latest `todo` object for next reload
            localStorage.setItem( 'todo', JSON.stringify(todo) );
console.log("the final output ",output);
            // Show Editor what has changed
            successCallback( output );
        }
    } );

The table definition

var editor; // use a global for the submit and return data rendering in the examples
// make sure to modify the column formating info in the datatables init structures
function buildTable()
{
    // Create or update the todo localStorage entry
    if ( localStorage.getItem('todo') ) {
        todo = JSON.parse( localStorage.getItem('todo') );
    }


    // Activate an inline edit on click of a table cell
    $('#myTable').on( 'click', 'tbody td:not(:first-child)', function (e) {
        console.log("the row ",t.row( this ).data());
        console.log("the row ",t.row( this ).index());
        $.extend( todo, t.row( this ).data() );
        editor.bubble( this );
        console.log(t.row);
    } );

    console.log("table is new");
    var t = $('#myTable').DataTable( {
     "destroy": true,
       "data": theTable.data,
       "columns": [
            {"data": "depotName"}, {"data": "clientName"}, {"data": "rtuName"}, {"data": "deviceName"}, {"data": "serialNumber"}, {"data": "assetNumber"},
            {"data": "serviceTag"}, {"data": "location"}, {"data": "ipAddress"}, {"data": "deviceType"}, {"data": "deviceStatusMessage"}, {"data": "quiesce"},
            {"data": "utilization"}, {"data": "coverage"}, {"data": "monoLifeCount"}, {"data": "colorLifeCount"}, {"data": "pageCountThisMonth"},
            {"data": "createdDate"}, {"data": "lastActiveDate"}, {"data": "deviceId"}
        ],
        "columnDefs":
        [
           {
            orderable: false,
            className: 'select-checkbox',
            targets:   0
           },
          { className: "dt-right", "targets": [12,13,14,15,16]}
        ],
        select: {
            style:    'os',
            selector: 'td:first-child'
        },
     "buttons" :
       [
          'colvis',
         { extend: "edit",   editor: editor },
         {
           extend: 'collection',
           text: 'Export',
           buttons:
           [
             { extend: 'print', exportOptions: { columns: [ ':visible' ]}},
             { extend: 'copyHtml5', exportOptions: { columns: [ ':visible' ]}},
             { extend: 'csvHtml5', exportOptions: { columns: [ ':visible' ]}},
             { extend: 'pdfHtml5', exportOptions: { columns: [ ':visible' ]}}
           ]
         }
       ]
    });
    t.buttons().container()
     .appendTo(document.getElementById("buttonPlacement"));
   document.getElementById("deviceTable").style.display="inline";
}

Pipelining data searching is not working what to do?

$
0
0

my jquery is as below

$.fn.dataTable.pipeline = function ( opts ) { // Configuration options var conf = $.extend( { pages: 5, // number of pages to cache url: '', // script url data: null, // function or object with parameters to send to the server // matching how `ajax.data` works in DataTables method: 'GET' // Ajax HTTP method }, opts ); // Private variables for storing the cache var cacheLower = -1; var cacheUpper = null; var cacheLastRequest = null; var cacheLastJson = null; return function ( request, drawCallback, settings ) { var ajax = false; var requestStart = request.start; var drawStart = request.start; var requestLength = request.length; var requestEnd = requestStart + requestLength; if ( settings.clearCache ) { // API requested that the cache be cleared ajax = true; settings.clearCache = false; } else if ( cacheLower < 0 || requestStart < cacheLower || requestEnd > cacheUpper ) { // outside cached data - need to make a request ajax = true; } else if ( JSON.stringify( request.order ) !== JSON.stringify( cacheLastRequest.order ) || JSON.stringify( request.columns ) !== JSON.stringify( cacheLastRequest.columns ) || JSON.stringify( request.search ) !== JSON.stringify( cacheLastRequest.search ) ) { // properties changed (ordering, columns, searching) ajax = true; } // Store the request for checking next time around cacheLastRequest = $.extend( true, {}, request ); if ( ajax ) { // Need data from the server if ( requestStart < cacheLower ) { requestStart = requestStart - (requestLength*(conf.pages-1)); if ( requestStart < 0 ) { requestStart = 0; } } cacheLower = requestStart; cacheUpper = requestStart + (requestLength * conf.pages); request.start = requestStart; request.length = requestLength*conf.pages; // Provide the same `data` options as DataTables. if ( $.isFunction ( conf.data ) ) { // As a function it is executed with the data object as an arg // for manipulation. If an object is returned, it is used as the // data object to submit var d = conf.data( request ); if ( d ) { $.extend( request, d ); } } else if ( $.isPlainObject( conf.data ) ) { // As an object, the data given extends the default $.extend( request, conf.data ); } settings.jqXHR = $.ajax( { "type": conf.method, "url": conf.url, "data": request, "dataType": "json", "cache": false, "success": function ( json ) { cacheLastJson = $.extend(true, {}, json); if ( cacheLower != drawStart ) { json.data.splice( 0, drawStart-cacheLower ); } if ( requestLength >= -1 ) { json.data.splice( requestLength, json.data.length ); } drawCallback( json ); } } ); } else { json = $.extend( true, {}, cacheLastJson ); json.draw = request.draw; // Update the echo for each response json.data.splice( 0, requestStart-cacheLower ); json.data.splice( requestLength, json.data.length ); drawCallback(json); } } }; // Register an API method that will empty the pipelined data, forcing an Ajax // fetch on the next draw (i.e. `table.clearPipeline().draw()`) $.fn.dataTable.Api.register( 'clearPipeline()', function () { return this.iterator( 'table', function ( settings ) { settings.clearCache = true; } ); } ); $(document).ready(function() { $('#data-table').DataTable( { "processing": true, "serverSide": true, "bFilter": true, "bSortable": true, "bRetrieve": true, "aoColumns": [{"sType":"string"}], "ajax": $.fn.dataTable.pipeline( { url: 'scripts/server_processing.php', pages:100// number of pages to cache } ), "search": { "regex": true }, "order": [[ 0, "desc" ]], "columnDefs": [{ "targets": 19, "orderable": false }], } ); } );

Searching and desc and asc order is not worlking here........Thanks in advance....!!!!

Scroll is not allowing overwrite of footer elements

$
0
0

Without the scrollX & scrollY parameters, the footer elements are successfully replaced with input boxes, allowing me to perform a column by column search. Once these parameters are included, the footer loses the input boxes.

I'm have this currently on http://live.datatables.net/sojeluju/1/edit

$(document).ready( function () {
var table = $('#example').DataTable({
"sPaginationType" : "full_numbers",
"ajax": "/examples/server_side/scripts/server_processing.php",
"processing" : true,
"serverSide" : true,
"fixedHeader" : true,
"lengthMenu" : [[10, 25, 50, 100, 200, -1],[10,25,50,100, 200, "All"]],
"pageLength" : 25,
"sScrollX" : "110%",
"sScrollY" : "600px",
"bScrollCollapse": true,
"columnDefs": [
{ "type": "signed-num", "targets": 3}
]
});

        $('#example tfoot th').each(function() {
           var title = $('#example thead th').eq($(this).index()).text();
           console.log(title);
           $(this).html('<input type="text" placeholder="Search ' + title + '"/>');
       });
       table.columns().every(function () {
           var datatableColumn = this;
           $(this.footer()).find('input').on('keyup change', function() {
               datatableColumn.search(this.value).draw();
           });
       });

} );

Viewing all 81388 articles
Browse latest View live


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