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

Issue with Moment.js plugin

$
0
0

Hi Allan,
with the fix provided by you the moment.js plugin works fine with format: 'L' now.

I also need to use format: 'LLL' though and this causes another problem.

While moment.js properly returns "11. Februar 2017 11:31" as "tomorrow" from this

momentLocale = 'de'; //used in Editor
moment.locale('de');
tomorrow = moment(currentTime).add(1, 'day').format('LLL');

there is however an issue using it in Editor:

{
                label: "End of Bid Period:",
                name:  "rfp.bidtime_end",
                type:  "datetime",
                def:   function () { return tomorrow },
                format: 'LLL',
                opts:  {
                    showWeekNumber: true,
                    momentLocale: momentLocale
                }
            }

The default works fine and displays "11. Februar 2017 11:31". If I pick a different date time and want to save it Editor sends this to the server: 0000-00-00 00:00:00. I could see it in my debugger. I tried with format: 'L'. That worked fine but it is not the format I need in this case. So the problem is really about the 'LLL' and Editor. I would really need most of these formats to work:
https://momentjs.com/
Please help.


Would DataTables prevent custom modals to be shown?

$
0
0

Hi all,

I've implemented DataTables and I really love it, but is it possible that DataTables DOM manipulation causes my custom modals not to be shown after clicking a button?

I have Delete buttons which trigger custom modal display and prevent default actions until the user decides.
When landing on the page these work, but after pagination or filtering these actions are not triggered. The records simply gets deleted, which is really dangerous.

Am I doing something wrong?

thank you.
seba

One Search button for two categories

$
0
0

Hi,

I have different categories in my table and I want to implement one search button to show two categories (of 5).

Actually I use this code:

{
                text: 'Purchased',
                action: function ( e, dt, node, config ) {
                    var table = $('#sites').DataTable();
                    table.columns( 1 ).search( "Purchased" ).draw();
                }
            },{
                text: 'Sold',
                action: function ( e, dt, node, config ) {
                    var table = $('#sites').DataTable();
                    table.columns( 1 ).search( "Sold" ).draw();
                }
            }

And I tried to change it into this (which doesn't work also with enabled regex):

{
                text: 'Purchased or Sold',
                action: function ( e, dt, node, config ) {
                    var table = $('#sites').DataTable();
                    table.columns( 1 ).search( "Purchased|Sold" ).draw();
                }
            }

Have anybody an idea to merge the to buttons without changing the categories?

Thanks in advance

Patrick

Editor - split a database column data into two editor fields

$
0
0

I have a database column, "start", defined as type DATETIME.

In the editor I would like to split "start" into two editor fields, date and time, so I can use separate "pickers".

Likewise, once created/edited I would like to combine the date and time editor fields back into the database column "start".

I would like the date in "MM/DD/YYYY" format and time in "hh:mm a" format.

Being a bit new to Datatables and Editor, I'm not sure where to start..

Any examples would be welcome.

Regards,
Jim

Server-side processing, empty JSON

$
0
0

Hi,

For a first try I would like to display only the ids of a table in a Datatable by using Serverside processing. But I'm searching for a few days and I can't success. I get a 'invalid json response' What's wrong with that :

<!DOCTYPE html>
<html>
    <head>
        <script type="text/javascript">
            var table;
            $(document).ready(function() {
                table = $('#table').DataTable({
                    "processing": true,
                    "serverSide": true,
                    "ajax": {
                        "url": "application/php/joinArray.php",
                        "type": "POST"
                    } ,
                "columns": [
                    { "data": "id" }]
                });
            });
        </script>
    </head>
<body>
    <div class="container">
        <table id="table" class="table table-striped table-bordered" cellspacing="0" width="100%">
            <thead>
                <tr>
                     <th>Id</th>
                </tr>
            </thead>
            <tfoot>
            <tr>
                     <th>Id</th>
            </tr>
            </tfoot>
        </table>
    </div>
</body>
</html>```


Server side phpscript :

<?php
include('../libraries/Editor-PHP-1.6.1/php/DataTables.php');
use
    DataTables\Editor,
    DataTables\Editor\Field,

Editor::inst( $db, 'interventions' )->fields(Field::inst('id'))->process($_POST)->json();
`

using a bootstrap dropdown button for the datatable.buttons

$
0
0

Is it possible to add the datatable buttons( print, csv, copy etc) to a bootstrap dropdown button?

I have tried several ways and just can't seem to figure it out. Does anybody know of any example code implementing this which i could use and modify?

Thank you.

Unable to add additional columns due to ajax error

$
0
0

Hello!

At the moment I'm attempting to add another column to my page. However, I will get an ajax error whenever I do. It's fine with 10 columns, but as soon as I add the 11th, the ajax error will appear.

Here's my debugger
http://debug.datatables.net/ewolon

And the console error shows:
responded with a status of 403 (Forbidden)

How to add Order by clause in Editor

$
0
0

Hi Support,
How can i add order by clause while data Fetch from Server.

Regards
Sunil


Trivial typo in the language.infoEmpty documention

Server side processing not working with C#.NET and large datasets

$
0
0

Hello,

I have a working datatable on my website until I added 200.000 rows to my sql table.
The data is not showing at all. I tried to open the ajax response in my browser but it gives me an xml error.
I looked in the forum and learned about server-side processing.
I added that option and i got an ajax error saying that i should visit datatables website for more information about the error

I removed my 200.000 rows and everything is working again.

is there something specific for the C# .NET in order to get server side processing working ?

Regards.

Converting [object] to URL in column

$
0
0

Hello,

Is there anyone that can take a look at my code and help me figure out why I'm receiving "[object Object]" instead of the URLs I should be receiving.

The data table is under a column called: URL with links formatted as "https://www.google.com".

Attached is what is rendered to the end user.

I attempted to follow a previous thread on this issue but im not understanding hope the issue was resolved. Please assist!
https://datatables.net/forums/discussion/27167/how-do-get-data-in-row-datatable

I added the following code which is now presenting me a link to object object.

"https://cloudsites.XXXX.com/sites/XXXXXX/SitePages/[object%20Object]"

{ "mData": "URL",
"mRender": function ( data, type, full )
{
return '<a href="'+data+'">Link</a>';
}
},

<script language="javascript">

$(document).ready(
function(){

// ajax call to get the list data using REST
var call = $.ajax({
url: _spPageContextInfo.webAbsoluteUrl + "/_api/Web/Lists/GetByTitle('TeamLinks')/items?$top=200",
type: "GET",
dataType: "json",
headers: {
Accept: "application/json;odata=verbose"
}
});

// this gets called when the AJAX completes.
// this populates the table created above

call.done(function (data,textStatus, jqXHR){
$('#example').dataTable({
"bDestroy": true,
"bProcessing": true,
"aaData": data.d.results,
"aoColumns": [
{ "mData": "br3e" },
{ "mData": "Comments" },
{ "mData": "URL" },
{ "mData": "Platform" }
],
dom: 'T<"top"if>rt<"bottom"lp><"clear">',
        tableTools: {
            "sSwfPath": "/sites/GPNOC/Style Library/swf/copy_csv_xls_pdf.swf"
        }
});
});


// Render clickable HTML

// called if the AJAX fails

call.fail(function (jqXHR,textStatus,errorThrown){
   alert("Error retrieving Tasks: " + jqXHR.responseText);
});
}

  );

</script>

SearchDelay for Server-side issue

$
0
0

Is that confirmed issue, or is it in my implementation only that the filter input fires twice. Once immediately on the first letter typed, and second time after the set delay time. I see that in few of my datatables implementations for version 1.10.10

How can i add dynamic field datatables editor ?

sorting and pagination locally with ajax load

$
0
0

For the benefit of other users:
I was able to activate the data table in hybrid mode.

The following configuration allow you to do an initial Post on load to your ajax function. The main difference is that with server side false , the post request has no parameters, if you require parameters you can build them int he query string for the post request definition in the ajax definition as shown below with the variable that defines the ajax URL definition.

                    var table = $('#bundletbl').DataTable({
                        processing: true,
                        serverSide: false,
                        lengthMenu: [10, 25, 50],
                        select: true,
                        dom: 'Blrtip',
            ajax: {
                                    "url": "<?php echo APP_URL ?>adm/ajax/partners?id" <?php echo $ID ?>,
                                    "type": "POST"
             },
             columns: [
                                            {
                                                className: 'details-control',
                                                orderable: false,
                                                data: null,
                                                defaultContent: ''
                                            },
                                            { "data": "partner" },
                                            { "data": "DT_RowId" },
                                            { "data": "appname" },
                                            { "data": "appid" },
                                            { "data": "apiurl" },
                                            { "data": "hostname" }
                                ]
             });

                    // Apply the search
                    table.columns().every(function () {
                        var that = this;

                        $('input', this.footer()).on('keyup change', function () {
                            if (that.search() !== this.value) {
                                that
                                    .search(this.value)
                                    .draw();
                            }
                        });
                    });

I was not able to find this specific solution in the forums nor stack overflow. The above allows you to load data tables with the initial load from the ajax Post call, then since server side is false the data tables jquery framework takes care of the search and the sorting. This is very efficient since ideally the initial query is reducing the amount of data shown for a user. Typically you will never display thousands of records for a given user and the performace is improved for the user given the fact that there is no need to do ajax call on every keystroke when searching.

If you require to refresh the table with ajax calls you can manipulate the ajax call with other methods or events.

Hope this will save time to other people who are looking for the same answer.

Selected row

$
0
0

I use this script to enable some buttons if a row is selected:

        ulist.on('select', function () {
            var selectedRows = ulist.rows( { selected: true } ).count();
            ulist.button( 1 ).enable( selectedRows === 1 );
            ulist.button( 2 ).enable( selectedRows === 1 );
            ulist.button( 3 ).enable( selectedRows === 1 );
        });

If the Page with the Table is new loaded, the Button are disabled. If I select a row the buttons are enabled.
I deselect the row, the buttons should now disabled again, but the Button are enabled and create an error if
you click on the Button without selection. How can I disable the button if the user have deselected all rows?

Andreas


Individual Search Columns not working in Fixed Columns

$
0
0

I have a table and applied a Fixed column on it fixing the first two columns which was successful on my end. In Addition to this, I also applied individual search columns but it seems to work only on the not fixed columns. It does not work on the fixed columns. If you need to see how I copied and reconstructed the JS here's the code.

$(document).ready(function() { $('#example tfoot th').each( function () { var title = $('#example thead th').eq( $(this).index() ).text(); $(this).html( '' ); } ); var table = $('#example').DataTable({ setTimeout: "50", scrollY: "350px", scrollX: true, scrollCollapse: true, paging: false, heightMatch: "auto", columnFilter: true, fixedColumns: { leftColumns: 2 }, }); table.columns().every( function () { var that = this; $( 'input', this.footer() ).on( 'keyup change', function () { that .search( this.value ) .draw(); } ); } ); });

<style type="text/css">
/* Ensure that the demo table scrolls */
th, td { white-space: nowrap; }
div.dataTables_wrapper {
width: 1210px;
margin: 0 0 0 0;
}
</style>

Note: To explain it more clear, I have let's say 6 columns and the first two columns (columns 1,2) are freezed/fixed. The indivudual column search works on 3,4,5,6 but not it 1 and 2.

DataTable is not a function

$
0
0

Hi all,
I'm taking the first steps on yii framework and datatables.
I'm trying to use DataTables on yii but i'm facing this issue:

Uncaught TypeError: $(...).DataTable is not a function
at HTMLDocument.<anonymous> (table_page:65)
at c (jquery.min.js:4)
at Object.fireWith [as resolveWith] (jquery.min.js:4)
at Function.ready (jquery.min.js:4)
at HTMLDocument.q (jquery.min.js:4)

The CODE i'm using:

<HTML>
<HEAD>
<TITLE>My first HTML document</TITLE>

 <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.13/css/jquery.dataTables.min.css">
<script type="text/javascript" language="javascript" src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script type="text/javascript" language="javascript" src="https://cdn.datatables.net/1.10.13/js/jquery.dataTables.min.js"></script>

  <script type="text/javascript" class="init">
    $(document).ready(function() {
var table = $('#example').DataTable();

$('#example tbody').on('click', 'tr', function () {
    var data = table.row( this ).data();
    alert( 'You clicked on '+data[0]+'\'s row' );
} );

} );
</script>

</HEAD>
<BODY>
<table id="example" class="display" cellspacing="0" width="100%">
<thead>
<tr>
<th>Name</th>
<th>Position</th>
(...)

When i use this code outside Yii this is working properly.
Anyone can help me?
Thanks in advance!

Delete my account

$
0
0

Hello there,

I have made an account which I never needed. Can I delete it, if yes what is the process?

Thanks!

Using datatable in salesforce lightning component

$
0
0

Hi,

I am using datatable in salesforce lighting component, its working fine expect I am getting this warning when lightning locker service is enabled.

WARNING: SecureElement: [object HTMLDivElement]{ key: {"namespace":"c"} } does not allow getting/setting the disabled attribute, ignoring!

Locker service in salesforce prevent:

Components from causing XSS and similar security issues
Components from reading other component’s rendered data without any restrictions
Components from calling undocumented/private APIs

I am afraid it might stop working some day.

Thanks,
Rehan

New Ajax call on page change

$
0
0

Hello,

First, thank you for this awesome plugin and I need to say I'm very new to jquery.

I'm using datatables with a non rdbms (like elasticsearch) system. I'm fetching records by using an api.

To be simple: I'm trying to make a new ajax request to the api for getting the new records on page change.

Records on the data source have a unique id and I can query them by using the api like;

http://localhost/myapi?getrecords[id:1-10]&total:10

this will return the records with IDs between 1 and 10, and total of 10 records.

On every page change I need to get the current page number and display size from the user and send a call like:

http://localhost/myapi?getrecords[id:((page*size)-size)-(page*size)]&total:(size)

for example, if my display size 10(size) records and I clicked the 2nd(page) page on pagination, it will return me the records with IDs between the 10 and 20. After that I will process the records and show them to user. (btw I also can get the total number of records from the api.)

Is it possible to achieve this on page change? If yes, where should I start?

Thank you.

Viewing all 81388 articles
Browse latest View live


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