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

Why data is loading slower in LIVE website?

$
0
0

I'm trying to load data from a table which contains 3k records. Data loads very fast in local server but when i deployed my code to server (live website) it takes 20-30 seconds to load the whole data.

My code:

```ajaxUrl: '<?php echo $this->MyHelper->Route('admin-get-blog-articles-faq')?>',
        columns: [
            my.common.admin.tableEditColumn('id'),
            { data: 'question' },
            { data: 'created_at' }
        ],```

Table code:

```<table id="records-table" class="table table-striped table-bordered" width="100%">
                                <thead>
                                    <tr>
                                        <th></th>
                                        <th class="hasinput">
                                            <input type="text" class="form-control filter" placeholder="Question">
                                        </th>
                                        <th class="hasinput">
                                            <input type="text" class="form-control filter" placeholder="Date Created">
                                        </th>
                                    </tr>
                                    <tr>
                                        <th></th>
                                        <th class="all">Question</th>
                                        <th class="all">Date Created</th>
                                    </tr>
                                </thead>
                                <tbody></tbody>
                            </table>```

Controller func:

```public function getBlogArticlesFaqAction() {

    //Get all Blog Articles FAQ from DB
    $blogArticlesFaq = BlogArticleFaqModel::getAllForDataTable(array('id', 'question', 'created_at'));

    // Return data array
    return array('data' => $blogArticlesFaq);
}```

Integration of deeplink.js into existing table

$
0
0

Hey Guys,
i have a little problem with the integration of the deepLink plugin into my existing table.

This is my original table

$(document).ready(function() {
   var dataTable = $('#mytable').DataTable( {
      "iDisplayLength": 30,
      "pagingType": "full",
      "ajax": "Database.txt",
   } );
} );

Now my table looks like this.

$(document).ready( function () {
   $('#mytable').DataTable( $.fn.dataTable.ext.deepLink( [
      'search.search'
       ] ) 
   );
});

So where do i have to place my settings, for example.

"iDisplayLength": 30,    or
"pagingType": "full",    or
"ajax": "Database.txt",

Does anyone know that ?
I know its a dumb question but i don't get it.
Thx Samu

Bootstrap 4 Buttons integration

problems with changing row with draw ()

$
0
0

I have a problem on changing row from data that come back from MySQL update I tried with the draw () function but I get this error:

datatables.min.js:129 Uncaught TypeError: Cannot set property '_aData' of undefined
at s.<anonymous> (datatables.min.js:129)
at s.data (datatables.min.js:115)
at Object.<anonymous> (functions.js:76)
at Function.each (jquery.min.js:2)
at Object.success (functions.js:58)
at i (jquery.min.js:2)
at Object.fireWith [as resolveWith] (jquery.min.js:2)
at y (jquery.min.js:4)
at XMLHttpRequest.c (jquery.min.js:4)

my script and this:

$.ajax({
type: "POST",
url: url,
data: form.serialize(),
success: function(data)
{
var json_txt = $.parseJSON(data);
$.each(json_txt, function(i, item) {

          id_day = item.id_day;
          portata = item.nome_port;
          piatto = item.nome_pia;
          descrizione = item.dsc_piatti;
          ingredienti = item.ingred;
          eng_piatti = item.ing_piatti;                

            var table = $('#example').DataTable();
                var tableRow = table.row( $('#update_table_' + id_day ) );
                var rData = [
                    portata,
                    piatto,
                    descrizione,
                    ingredienti,
                    eng_piatti,
                ]; 
                table.row( tableRow ).data( rData ).draw();

         });
        }
     });    

I do not understand the mistake you can help me?

P.S. sorry for my english

Scroll to a specific column on page load

$
0
0

Hi! Is it possible to scroll to a specific column automatically when page loads? I see that it's possible for rows with row(x).scrollTo();... I want to do the same, but with columns...

Start horizontal scroll bar on particular column

$
0
0

Hi! I'm using datatables with multiple fixed columns and complex header. Is it possible to start the horizontal scroll bar just on the first non fixed column?

Validator error for file restrictions

$
0
0

I am using the editor for a site that I am working on and I came across this error
Illegal string offset 'name' in ..\Editor\Validate.php on line 1064
I'm unsure why this error is occurring as the validate file should be up to date. For the server side script, I followed the example that is posted on the site. I'll put the segment of code that it is referring to.

[Code]
`
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* File validation methods
*/
static function fileExtensions ( $extensions, $msg="This file type cannot be uploaded." ) {
return function ( $file ) use ( $extensions, $msg ) {
$extn = pathinfo($file['name'], PATHINFO_EXTENSION);

        for ( $i=0, $ien=count($extensions) ; $i<$ien ; $i++ ) {
            if ( strtolower( $extn ) === strtolower( $extensions[$i] ) ) {
                return true;
            }
        }

        return $msg;
    };
}

static function fileSize ( $size, $msg="Uploaded file is too large." ) {
    return function ( $file ) use ( $size, $msg ) {
        return $file['size'] > $size ?
            $msg :
            true;
    };
}

`[/Code]

Smart Search Table not working on Smart Phone

$
0
0

I added a smart search table on my sample site surprisingly on the first try: https://databasetable-net.000webhostapp.com/

The table is fully responsive on a computer when you make the screen smaller. However, the table pushes left on a smart phone.

This article solution of adding the css: #smart_table{ margin: 0 auto; } did not work.
https://datatables.net/forums/discussion/45913/table-not-centered
Removing the boostrap contrainer also did not work (as that could conflict with datatables CDN). Adding a col-xs-10 container also did not seem to have an impact.

Here is my full code if needed:

<!--========= ADVANCED SEARCH ===============-->

 <center><div class="container-fluid"><h4>Advanced Multi-Search Option (see below)</h4>  <br>

<table class="table table-striped table-bordered table-hover table-condensed" cellpadding="3" cellspacing="0" border="0" style="width: 70%; margin: 0 auto 2em auto;" id="smart_table">
        <thead>
            <tr>
                <th>Target</th>
                <th>Search text</th>
                <th>Treat as regex</th>
                <th>Use smart search</th>
            </tr>
        </thead>
        <tbody>
            <tr id="filter_global">
                <td>Global search</td>
                <td align="center"><input type="text" class="global_filter" id="global_filter"></td>
                <td align="center"><input type="checkbox" class="global_filter" id="global_regex"></td>
                <td align="center"><input type="checkbox" class="global_filter" id="global_smart" checked="checked"></td>
            </tr>
            <tr id="filter_col1" data-column="0">
                <td>Column - ID</td>
                <td align="center"><input type="text" class="column_filter" id="col0_filter"></td>
                <td align="center"><input type="checkbox" class="column_filter" id="col0_regex"></td>
                <td align="center"><input type="checkbox" class="column_filter" id="col0_smart" checked="checked"></td>
            </tr>
            <tr id="filter_col2" data-column="1">
                <td>Column - First Name</td>
                <td align="center"><input type="text" class="column_filter" id="col1_filter"></td>
                <td align="center"><input type="checkbox" class="column_filter" id="col1_regex"></td>
                <td align="center"><input type="checkbox" class="column_filter" id="col1_smart" checked="checked"></td>
            </tr>
            <tr id="filter_col3" data-column="2">
                <td>Column - Last Name</td>
                <td align="center"><input type="text" class="column_filter" id="col2_filter"></td>
                <td align="center"><input type="checkbox" class="column_filter" id="col2_regex"></td>
                <td align="center"><input type="checkbox" class="column_filter" id="col2_smart" checked="checked"></td>
            </tr>
            <tr id="filter_col4" data-column="3">
                <td>Column - Zip</td>
                <td align="center"><input type="text" class="column_filter" id="col3_filter"></td>
                <td align="center"><input type="checkbox" class="column_filter" id="col3_regex"></td>
                <td align="center"><input type="checkbox" class="column_filter" id="col3_smart" checked="checked"></td>
            </tr>
            <tr id="filter_col5" data-column="4">
                <td>Column - Date</td>
                <td align="center"><input type="text" class="column_filter" id="col4_filter"></td>
                <td align="center"><input type="checkbox" class="column_filter" id="col4_regex"></td>
                <td align="center"><input type="checkbox" class="column_filter" id="col4_smart" checked="checked"></td>
                 <tr id="filter_col5" data-column="4">
                <td>Column - Updated</td>
                <td align="center"><input type="text" class="column_filter" id="col4_filter"></td>
                <td align="center"><input type="checkbox" class="column_filter" id="col4_regex"></td>
                <td align="center"><input type="checkbox" class="column_filter" id="col4_smart" checked="checked"></td>
            </tr>

        </tbody>
    </table> 
    </div> </center>
    <br>
     <center><div class="container-fluid"><h5>Smart search built-in filtering is "smart" in that it breaks the user's input into individual words and then matches those words in any position and in any order in the table (rather than simple doing a simple string compare). <a href="https://datatables.net/reference/option/search.smart" target="_blank">Click here for more info!</a></h5> </div> </center> <br>
</body>
  </html>

  <script type="text/javascript"> 
  $(document).ready(function() {
function filterGlobal () {
    $('#example').DataTable().search(
        $('#global_filter').val(),
        $('#global_regex').prop('checked'),
        $('#global_smart').prop('checked')
    ).draw();
}

function filterColumn ( i ) {
    $('#example').DataTable().column( i ).search(
        $('#col'+i+'_filter').val(),
        $('#col'+i+'_regex').prop('checked'),
        $('#col'+i+'_smart').prop('checked')
    ).draw();
}

$(document).ready(function() {
    $('#example').DataTable();

    $('input.global_filter').on( 'keyup click', function () {
        filterGlobal();
    } );

    $('input.column_filter').on( 'keyup click', function () {
        filterColumn( $(this).parents('tr').attr('data-column') );
    } );
} );
} ); //end
</script>

Optional pagination button

$
0
0

Consider the datatable rows all fit in the panel where they are rendered. Then the pagination control buttons need not be displayed. If the table is large then they should be shown. Is there an easy way to model this behavior?

ajax error callback

$
0
0

The API provides callbacks for successful AJAX calls but what about when something goes wrong? For example, if the user's session has been killed, the REST call might return a 403. How do I deal with that? For example, ajax.reload only provides a success callback as far as I can tell.

Responsive table issues

$
0
0
  1. If I set data-priority tags on the 2nd 3rd and 4th and last column of a table, but not the first, when the table shrinks enough so that the first column is hidden, there's no plus sign to show the table data.
  2. if I have an additional table header row with column based filters, and the page shrinks enough to make a column get hidden, the extra header row and input box isn't hidden. This may compound some of the other issues that I'm seeing. Incidentally, my aggregate footer rows get hidden as expected, as does the column visibility button
  3. If I have a table with a bunch of rows, and I set the priority on 4 of them (as mentioned in the first issue), none of those 4 ever get hidden no matter how small the page gets. Possibly this is caused by the fact that there are still a bunch of extra unhidden header rows due to issue 2
  4. if I have tooltips/popovers/confirmations that I set up in the table, those don't get cloned in the responsive/hidden rows. This is especially problematic when I have something like a delete button with using a confirmation widget to make deletion a 2 step process, but it's annoying when I have a tooltip for an acronym in the table that winds up not working either.

I'll work on examples shortly

Excel output, date field, exporting to excel as a date field type for filtering/sorting purposes

$
0
0

I've got a table that has a date field (well, many tables with many date fields, but one in particular).

I've got a user who is trying to export to excel and then do some querying on it, particularly looking at events that fall into a specific date range.

the problem we're running into is that in the excel output, the date field is just text, and he's not getting any excel's filtering or sorting options to work with the date.

I haven't spent much time digging into it yet, but this seems like something that has to have cropped up before.

dates are mm/dd/yyyy if it's relevant

How to access editor data without using a field? Or is a hidden field my best option?

$
0
0

I am slowly trying to move my codebase to be a more standalone editor driven so I can have editors open inside of other editors (nested editors). All of my customers keep asking if they could add items to dropdowns on the fly without being taken to another CRUD UI in another tab (if you have any alternative solutions for that I am all ears).

Currently, I have to have an instance of my DataTable table because not everything is a field. Some stuff is just data for display in the table and used as a reference for the editor. Think DeletedOnDate, that would not be editable but on editor open event might be used to change all sorts of things based on if a record is soft deleted or not.

I realize I could probably just use a hidden field for this data, but i didn't know if there was a "bucket" option I could use for my editor to have a deep well of data to use that are not fields. But for this to be really modular, I can't have my editor dialog rely on the table data in case I want to re-use all of my editor event logic inside of another editor.

Non Order Column - show stop icon

$
0
0

Hello Everyone,

I saw somewhere for a non orderable column, when mouse over on column header

<th>Actions</th> , you see a stop icon.

Q1) How do I achieve this please in using DataTable

Q2) in my code below i got edit, delete and read buttons, i would like to know how I could call a modal window and pass or bind the data:'id' value, so the respective modal window will open with the correct record.

Q3) The search on date filed, in my case is hiredata, the datatable search for dates, how to achieve this please.

                             'columns': [{
                                    data: 'id'
                                },
                                {
                                    data: 'emp_name'
                                },
                                {
                                    data: 'salary'
                                },
                                {
                                    data: 'gender'
                                },
                                {
                                    data: 'city'
                                },
    {
                                    data: 'hiredate'
                                },
                                        {


                             "bSortable": false,
                            "orderable":      false,
                            "data":  "null",
                            "className": "center",
                    "defaultContent": '<a type="button" class="edit btn btn-default btn-sm"> <span class="glyphicon glyphicon-edit"></span></a>  <a type="button" class="delete btn btn-default btn-sm" > <span class="glyphicon glyphicon-trash"></span></a>  <a type="button" class="view btn btn-default btn-sm" > <i class="fa fa-folder-open" aria-hidden="true"></i></a>'

                        }
                            ]

Is any possible update only assigned rows in server side

$
0
0

I found that when I use editor to create or update the row in serve side mode and use drawType: 'page', option, it it will refetch all the data each time, I think this is slow and waste, So how can I update only the changed row ?


Filter the list in a combobox

$
0
0

Hi,
I want to filter the list in a combobox, from a datatable editor. When I use the where condition, I do not have any errors, but it does not return any records.

Editor::inst( $db, 'tb_diccionario' )
->field(
Field::inst( 'tb_diccionario.materia_id' )
->options( Options::inst()
->table( 'tb_materia' )
->value( 'id' )
->label( 'materia' )
->where( 'tb_materia.activo', 1 )
),
Field::inst( 'tb_materia.materia' ),

->leftJoin( 'tb_materia', 'tb_materia.id', '=', 'tb_diccionario.materia_id' )

*Activo es un campo de la tabla materia de tipo tinyint.

filtering table with a checkbox.

$
0
0

There is a checkbox on my page that is supposed to filter the table so that it displays only rows with one error or more. I had implemented this function before and it worked fine. It stopped working all of a sudden when I changed the way that ajax was being called in my code (this was necessary as it was preventing ajax.reload() from working). This is my code which was working before:

    $('input[name=checkB]').change(function () {
                    if ($("#checkB").is(":checked")) {
                        $.fn.dataTable.ext.search.push(
                            function (settings, data, dataIndex) {
                                var num = Number(data[4]);
                                if (num > 0) {
                                    return true;
                                }
                                return false;
                            }
                        );
                    }
                    else {
                        $.fn.dataTable.ext.search.pop();
                        tTable.draw();
                    }
                });

I have since tried the following code instead with no luck:

document.addEventListener("DOMContentLoaded", function (event) {
                var selector = document.querySelector('input[name=checkB]');
                selector.addEventListener('change', function (event) {
                    if (selector.checked) {
                        $.fn.dataTable.ext.search.push(
                            function (settings, data, dataIndex) {
                                var num = Number(data[4]);
                                if (num > 0) {
                                    return true;
                                }
                                return false;
                            }
                        );
                    } else {
                        $.fn.dataTable.ext.search.pop();
                        tTable.draw();
                    }
                });
            });

Anyone have any idea why this has stopped working or how to fix this?
Many thanks

Responsive table doesn't work for two tables with renderer listHiddenNodes()

$
0
0

Hi Allen
First, I am sorry for my poor english.
I have a Problem, wenn I use responsive PlugIn and renderer listHiddenNodes for two tables.

http://live.datatables.net/hiqarowi/1/edit

you can make the window smaller and open the first row in first table.
And then you can open the first row in second table
but the sub-column in first Table disappears.
now you can open and close the details row and resize the window.
the Result ist totally wrong

can you take a look at it.
thank you

Editing a field returns an error (system error has occurred)

$
0
0

I'm trying to implement the inline edition of fields of a datatable.
When clicking on the field, the value is edited and everything seems to be right but this message appears below the datatable field (in the cell) after updating correctly the database table:

"A system error has occurred (More information)."

More information references => https://datatables.net/manual/tech-notes/12

The edited field keeps then the focus obliging to refresh the page.

Here is the json answer (valid json following https://jsonlint.com/)

"{\"data\":[{\"DT_RowId\":\"row_12662460\",\"ds_pluv\":\"555\"}]}"

I have also used debug datatables and the result is "15 tests complete. No failures or warnings found!"

Is it possible to get any help for this problem ? I'm stuck with this, and I wonder if it could be a bug.

Xavier

Dropdown not working inside jquery datatable mobile view

Viewing all 81384 articles
Browse latest View live


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