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

stateLoadCallback causing strange error on nextPage click and leading zeros on page info

$
0
0

Hi,

I've uploaded a config report ref: afebor

I'm saving and loading state info to and from a MySql source via ajax using typical ajax methods. Everything works perfectly well except for two strange glitches.

  1. The "info"string is displaying like:- Showing 01 to 025 of 52 entries (Notice leading zeros)
  2. The "pagingType": "full_numbers" is working OK except for the NEXT button. When clicked, the console reports the error:- TypeError: w is undefined

My Save and Load code in the dataTables script is as follows:-

var tbl = $('#' + tableId).DataTable( {
  stateSave: true,
                    stateSaveCallback: function (settings, ssData) {
                        $.ajax({
                            url: '" . URL . "myaccount/saveview/' + tableId,
                            data: ssData,
                            dataType: 'json',
                            type: 'POST',
                            success: function(){}
                        });
                    },
                stateLoadCallback: function (settings, callback) {
                        $.ajax( {
                            url: '" . URL . "myaccount/loadview/' + tableId,
                            dataType: 'json',

                            success: function (json) {
                                callback(json);
                            }
                        });
                }

My php code in my controller is:-

public function loadView($table_id)
    {
        $json = UserModel::getMyTableView($table_id);

        echo $json; 
    }
    public function saveView($table_id)
    {
        $json = json_encode($_POST);

        // if we don't clean the POSTed data then "columns":[{"visible":"false" wont work on stateLoadCallback(). it needs to be "columns":[{"visible":false
        $clean = str_replace('"false"', 'false', $json); 

        echo UserModel::saveView($table_id, $clean);
    }

and in my model, the code is:-

    public static function getMyTableView($table_id)
        {
            $sql = "SELECT state_save FROM user_views WHERE user_id = :user_id AND table_id = :table_id LIMIT 1";

            $database = DatabaseFactory::getFactory()->getConnection();

            $query = $database->prepare($sql);
            $query->execute(array(':user_id' => Session::get('user_id'), ':table_id' => $table_id));

            $row = $query->fetch();

            if (empty($row))
            {
                return json_encode(array());
            } else {
                return $row->state_save;
            }
        }

        public static function saveView($table_id, $post)
        {

            $sql = "INSERT INTO user_views (user_id, table_id, state_save) VALUES (:user_id, :table_id, :state_save) ON DUPLICATE KEY UPDATE table_id = :table_id, state_save = :state_save";

            $database = DatabaseFactory::getFactory()->getConnection();
            $query = $database->prepare($sql);
            //$query->execute(array(':table_id' => $post['table_id'], ':column_list' => $post['column_list'], ':user_id' => Session::get('user_id')));
            $query->execute(array(':table_id' => $table_id, ':state_save' => $post, ':user_id' => Session::get('user_id')));

            if ($query->rowCount()) {
                    return 'Layout Saved';
            }
            return 'The layout could not be saved';
        }

I've ran the debugger on my table and received no errors or warnings and I can't find anything that refers to this sort of problem

Thank you


Angular 8 server-side datatable with Laravel framework

$
0
0

Hello, I am trying to list the data that comes from an api in Laravel, I am using Yajra and it returns a result in this way

in component.ts the following code:

in html:

Apparently the page works but it does not show the registers despite the fact that in console

I hope you can help me please

Rendering Complex Data from JSON file

$
0
0

Ok, so this one has really got me stumped - Currently, I'm allowing a user to upload a JSON file into Datatables, and then I'm rendering the primary data in the columns, and additionally the more granular data I'm putting into a child row for each of the parent rows. The only thing is, some of the data for a particular data type within the JSON isn't explicitly stated. Take the following data for example:

{
  "id": "44a8ab7b-ce49-4fb2-8892-3c5d6ac43805",
  "game": "1",
  "nonce": 655,
  "currency": "USD",
  "amount": 0.002,
  "payoutMultiplier": 3.456700086593628,
  "payout": 0.00691339830729166,
  "createdAt": "2020-02-03T05:13:39.204Z",
  "updatedAt": "2020-02-03T05:13:50.819Z",
  "stateGame1": {
    "rounds": [
      {
        "number": 33,
        "answer": "higherEqual",
        "payoutMultiplier": 1.2869999408721924
      },
      {
        "number": 0,
        "answer": "lowerEqual",
        "payoutMultiplier": 1.6730999946594238
      },
      {
        "number": 18,
        "answer": "higherEqual",
        "payoutMultiplier": 1.8125250339508057
      },
      {
        "number": 42,
        "answer": "higherEqual",
        "payoutMultiplier": 2.9453530311584473
      },
      {
        "number": 42,
        "answer": "lowerEqual",
        "payoutMultiplier": 3.1907992362976074
      },
      {
        "number": 20,
        "answer": "lowerEqual",
        "payoutMultiplier": 3.4566991329193115
      }
    ],
    "startCard": 10
  },
  "SeedHash": "b69f0830ef4e0f8996a9de5fd53ea4e4b3fb8897cd2b88122510d4f06c864971",
  "clientSeed": "41ba497f4014"
}

As you can see, under stateGame1 -> rounds, there is "number", "answer", and "payoutMultiplier". My question is how would I go about selecting these data points to render into the datatables child row? Also, the fact that it has "rounds" also kinda throws me off. Im currently able to display data if say the JSON file just has stateGame1, but I'm not sure how to drill down further to rounds. If possible, Id really like to selectively choose the data within rounds, but i'm not sure how to do that given that all of them use the same identifier. To make things even more difficult, the number of data points under rounds can vary. Any ideas on how to accomplish this? Below is my script so far, so you can see how I'm displaying the data on simpler entries with just stateGame1 for example and not using the rounds identifier:

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

How to integrate with word press site

Which should be used: aoColumns or columns?

$
0
0

I wanted to have a custom sort function for a column in my table. I could find an example, which used aoColumns option, and my goal of custom sorting is achieved as well. However, is aoColumns a legacy option? Should I be using columns option?

This is how my datatable initialization looks:

myTab.DataTable({
aoColumns: [
{"sWidth":"40%", "bSortable":true},
{"sWidth":"60%", "bSortable":true, "sType":"customDate"}
]
});

Thanks.

Multiple DataTables Selecting

$
0
0

Hello

Im want first install selecting item and selecting change two table changed data
Im using server side option

Do you have tips or examples

when the table after the event xhr completes the creation of all elements DOM?

$
0
0

the fact is that in my table one column contains elements input.which I need to access after downloading data from the server.
however, when trying to access immediately after the event xhr I fail because the required item is not there yet. Tell me which event is better for me to use for my purpose?

How to perform several consecutive CSV imports

$
0
0

Hello,

I am facing an issue when I try to import several consecutive CSV file in my tables.

I look into your example : https://editor.datatables.net/examples/extensions/import
The issue also exists : if you import a CSV file into the table, and then try to import another CSV file the import form will open but you cannot load a file from your computer.

Do you have any clue to correct this issue ?

Thanks


table.editor() results in 'undefined'

$
0
0

Hi,

I am using a local inline editor with submit on blur which works just fine.

Now, I also want to submit just edited values when the submit button of the whole form is clicked. However, when the submit button is directly clicked, the submit on blur does not take effect.

Therefore, I call a JavaScript function before the actual submit action. In the JavaScript function I manually trigger editor.submit(). This also works fine as you can see in this example.

However, when I use the same submit() JavaScript function in my code, the editor variable is always undefined.

Any idea what could cause this issue?

Can this be narrowed down to some specific calls which I could post here? I do not want to post the whole JavaScript code here.

How to inline edit the data in the row and update the same in a datatable

$
0
0

I want to edit the data in the table with inline editing.
I want to do the following flow
1. Clicking the edit button, selected row should be enable to edit along with Update and cancel button should show.
2. Clicking update button, updates the change.

Doing this on MVC 5.

Editor in WebForm .Net and C# postback doesnt get new values

$
0
0

I have the code of GridView and it turn to datatable with editor, when i click in one row (inline editor) i change the values of any cell after i use a button to do the (Submit) the Server (C#) dont get the edited values, it returns the original values, how i can solve it? im using Web Form with C# and .Net

Code: https://jsfiddle.net/JuJoGuAl/m5sqebvd/

How i can solve it?

Setting background on row.data change

$
0
0

I need to set the background of the cell depending by the value of the associated data.
in my tbale I've set the 'createdCell' event:

            {
                "targets": 5,
                "createdCell": function (td, cellData, rowData, row, col) {
                    if (tipoRecord === 'Ricevuti' && rowData.Gestore !== '') {
                        $(td).css('background-color', rowData.GestoreColor);
                    }
                }
            }

When I update the value of the cell with row.data(newdata), other values of the row are changed correctly, but the 'createdCell' event is not called, so the Background doesn't change.
How can I set the background on data update?

Language and back to top

DATATABLE EXPORTAR

AJAX and JS-render

$
0
0

Hi,

I'm new to (web)dev so sorry for that. I created a database on my webserver, connected it/fetch data and render it into datatables (with images) see: http://eep.fifaplanet.eu/convertcsv.php

I just filtered the selection to ~200 entries. If I just select all entries (~20.000) the page loads for 2 minutes and needs much ressources.

I was looking around for a solution and saw each time "AJAX" and "serverside". There examples how to connect/fetch my database with AJAX but can I just render the rows with my current javascript function?
This is how I do it currently:

$(document).ready(function() {
    $('#example').DataTable( {
        "columnDefs": [
            {
                "targets": [ 0 ],
                "visible": false,
            },
            {
                "targets": [ 1 ],
                "data": "playerid",
                "render": function (data, type, row, meta) {
                return type === 'display'
                  ? '<div class="image-plus-text"><img style="width:64px" src="/Minifaces/' + row[0] + ".png" +  '"/>'+ "<br>" + data  + '</div>'
                  : data;
      }

[...]

How can I do it afterI'm using AJAX?


Value containing is "encoded" at display, how to show raw. JsFiddle link included!

$
0
0

Hi,
I've search and the forum quite a bit and could not find out how to display a url contains & characters, they seems to be encoded all the time but need help to display it as they are.

I've tried with entityDecode and escape() but no luck.

Here is a minimal example if someone know the solution.

https://jsfiddle.net/zdn8tmvx/

The url to display inside the cell is:

http://example.com/?amount=1&currency=USD

.draw() not working

$
0
0

Here is the example:

https://codesandbox.io/s/trusting-chandrasekhar-usenq

So why exactly is .draw() not working? The drawCallback never fires and the table shoes the records in the wrong order. In the console you can see the correct ordered data.

I thought by calling ".draw" I would update the DataTable.

Hello, this is my first post and first time using datatables.

$
0
0

I am trying to find out if my users can create/duplicate a table from the front end on their dashboard.

Ex. click to create a new table, table is created with or without its own database (possible using a master DB showing only their user_id data, then save.

Edit, add and delete rows and info, the the ability to save that table for later use.

Any assistance would be appreciated. If there is anyone interested in programming for this project, I would be open to discussing this.

Thanks... Dan

Editor Modal Width in Bootstrap 4

$
0
0

Is there a way to increase the modal width? At present, the width is 500px, which is the size of a BS4 standard modal. Can it be increased to modal-lg?

Many thanks for your help in advance.

Kind regards

TinyMCE not loading content on first load

$
0
0

The first time that I edit a row (as a modal), the TinyMCE editor loads properly, but it does not load existing content. Closing and re-opening does show the content, and indeed shows the content for all future calls until the page is reloaded.

I have tried loading TinyMCE without any options.

The strange thing is I always get this problem when calling the TinyMCE script (min.js) from a local file on the server. If I load it from the CDN (version 4.9.8), I do not get the problem. I have verified that the versions are the same and the file comparison is identical.

I need to run this locally on a server without access to the CDN in future, so could do with getting this to work. Any ideas?

Many thanks in advance.

Ronnie

Viewing all 82760 articles
Browse latest View live


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