Search
14752 results 4741-4750
Forum
- 2nd Apr 2013Entering information into a new tableTo my mind DataTables needs some data in order to be able to let you edit it and at least show the table without the "no records found" message. You could make that option an empty string using the i18n options. Possibly it should be allowed to be null and DataTables won't add it to the table. However, reading Anahita's issue, that sounds like a flaw in the editable plug-in. It probably needs a check added to it to see if the cell is the empty table cell or not (there is a class that it can use to check). I'd suggest opening an issue against that project. Allan
- 3rd Feb 2012fnGetData not returning row informationWell, I restructured how my app was put together (for other reasons), and it seems to be working now. Not sure what was going on, but I really appreciate you looking at it! :-) Thanks Allan.
- 8th Dec 2021DataTables warning: table id=user_data - Invalid JSON response. For more information about this erroindex.php <!doctype html> <html lang="en"> <head> <!-- Required meta tags --> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <!-- Bootstrap CSS --> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet"> <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/v/bs5/jq-3.6.0/dt-1.11.3/datatables.min.css" /> <title>Jquery DataTable CRUD</title> </head> <body> <div class="container-fluid"> <div class="w-100 d-flex align-item-center justify-content-center"> <div class="col-md-8 p-2"> <table id="user_data" class="table table-striped"> <thead> <tr> <th scope="col">sl No.</th> <th scope="col">Name</th> <th scope="col">Phone</th> <th scope="col">Email</th> <th scope="col">Address</th> <th scope="col">Action</th> </tr> </thead> <tbody> </tbody> </table> </div> </div> </div> <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> <script type="text/javascript" src="https://cdn.datatables.net/v/bs5/jq-3.6.0/dt-1.11.3/datatables.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script> <script> $(document).ready(function () { // var dataTable = $('#datatable').DataTable({ // 'processing': true, // 'serverSide': true, // 'order': [], // 'ajax': { // 'type' : 'POST', // 'url' : 'backend.php', // }, // 'columnDefs': [{ // 'target': [0, 5], // 'orderable': false, // }, ], // }); $.ajax({ type: "POST", url: "backend.php", // data: "data", dataType: "JSON", success: function (data) { $('#user_data').DataTable({ processing: true, serverSide: true, deferRender: true, ordering: false, pagingType: 'full_numbers', 'columnDefs': [{ 'target': [0, 5], 'orderable': false, }, ], }); } }); }); </script> </body> </html> backend.php' ``` <?php $servername = "localhost"; $username = "root"; $password = ""; $db = "jquerydatatable"; // Connection $conn = mysqli_connect($servername,$username, $password, $db); // Check if connection is // Successful or not if (!$conn) { die("Connection failed: " . mysqli_connect_error()); } // echo "all set"; // if(isset($_POST['data'])) // { $query = "SELECT * FROM mytable"; $res = mysqli_query($conn, $query); $count_row = mysqli_num_rows($res); // for search box if(isset($_POST['search']['value'])){ $serachValue = $_POST['search']['value']; $query .= "WHERE name LIKE '%".$serachValue."%'"; $query .= "WHERE phone LIKE '%".$serachValue."%'"; $query .= "WHERE email LIKE '%".$serachValue."%'"; $query .= "WHERE address LIKE '%".$serachValue."%'"; } // for order if(isset($_POST['order'])){ $column = $_POST['order'][0]['column']; $order = $_POST['order'][0]['dir']; $query .= "ORDER BY '".$column."' ".$order; } else{ $query .= "ORDER BY id ASC"; } // pegination // if(isset($_POST["length"]) != -1){ // $query .= "LIMIT ".$_POST['start'].", ".$_POST['length']; // } $data = array(); $res2 = mysqli_query($conn,$query); $filterd_rows = mysqli_num_rows($res2); while($arr = mysqli_fetch_assoc($res2)){ $subArray = array(); $subArray[] = $arr['id']; $subArray[] = $arr['name']; $subArray[] = $arr['phone']; $subArray[] = $arr['email']; $subArray[] = $arr['address']; $subArray[] = '<div class="btn-group" role="group" aria-label="Action Buttons"> <button type="button" class="btn btn-sm btn-success">Edit</button> <button type="button" class="btn btn-sm btn-danger">Delete</button> </div>'; $data[] = $subArray; } $output = array( "draw" => intval(isset($_POST['draw'])), 'recordsTotal' => $count_row, 'recordsFiltered' => $filterd_rows, 'data' => $data, ); // echo json_encode($output); echo json_encode($output); // echo json_encode(array("data" => $output)); // } HERE SHOW LENGTH , START AND DRAW IS UNDEFIND THST IS WHAY I WAS COMMENT IT ... PLEASE CHECK MY CODE AND PLEASE GIVE ME THE REPLY
- 2nd Mar 2017Doesn´t show all information to export a large table in pdf with pdfHtml5Hello everybody. I have a problem when i try to export a table with 20 columns, only show 17 columns, change orientation and paper size, so you know what happend? this my code $("#idTablaReporteECMMensajesError").dataTable({ "data": data, tabla: "#idTablaReporteECMMensajesError", dom: 'Blfrtip', buttons: [{ extend: 'collection', text: DATBLG, buttons: [ { extend: 'excelHtml5', title: RPRMM, }, { extend: 'pdfHtml5', title: RPRMM, exportOptions: { columns: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,18,19,20] }, customize: function (doc) { // Splice the image in after the header, but before the table console.log('doc.cont', doc.content); //console.log('doc.cont', doc.content.table); //console.log('doc.cont', doc.content.body); var columns= [] for (var i = 0; i < doc.content[1].table.body[0].length; i++) { columns.push("*"); } doc.content[1].table.widths = columns; }, orientation: 'landscape', pageSize: 'TABLOID' }, { extend: 'csvHtml5', title: RPRMM, }] }], "colVis": { "showAll": RPTXTALL, "showNone": RPTXTNOT, "buttonText": RPTXTMO }, "order":[[2, "asc"]], stateSave: true, "lengthMenu": [500, 1000, 1500], "scrollY": 250, "scrollCollapse": true, "scrollX": true, "columns": that.columnsReporteECMMensajesMotor, select: { style: 'os', selector: 'tr' } });
- 2nd Feb 2016Search child rows ( extra / detailed information)Please, is it possible to search data that is not contained in a table but in child rows?
- 2nd Dec 2014Child rows (show extra / detailed information) not working properly with Individual column searchingHere is my example: http://dev.ostcm.com/examples/api/row_details.html When an individual column is filtered the details button will only work on the 2nd click or after clicking in the tbody then clicking the details-control column. I was able to reproduce the issue in Chrome 39.0.2171.71 and IE 10. Firefox does work on the 1st click. Any help would be greatly appreciated.
- 29th Nov 2014Child rows (show extra / detailed information), how to it with nested data ?Hi, I was inspired by this example ? http://www.datatables.net/examples/api/row_details.html so I tried to duplicate it in jsfiddle, I want when the user click in the plus icon it will show some extra data. http://s22.postimg.org/bh3lnyy9d/Screen_Shot_2014_11_29_at_3_49_59_PM.png 1) can you please help me on how to construct the ajax data to have "agencies" and "globals" in the json : Is this correct : { "data": [ { "name": "Tiger Nixon", "position": "System Architect", "salary": "$320,800", "start_date": "2011/04/25", "office": "Edinburgh", "extn": "5421", "agencies": { "name": "agency2", "name": "agency5", "name": "agency24", }, "globals": { "name": "global42", "name": "global13", "name": "global4", } }, ...... ...... { "name": "Donna Snider", "position": "Customer Support", "salary": "$112,000", "start_date": "2011/01/25", "office": "New York", "extn": "4226", "agencies": { "name": "agency23", "name": "agency56", "name": "agency2", }, "globals": { "name": "global2", "name": "global13", "name": "global45", } } ] } 2) How to change that format function to get data from the json, here is my fiddle : http://jsfiddle.net/mlotfi/c918of1t/
- 10th Nov 2013server-side processing example with hidden row information not show detailsHi, i am using http://datatables.net/release-datatables/examples/server_side/row_details.html. Data visible runs correctly with "scripts/details_col.php" but when i click open.png not open row detalis. I have just changed the code to add more columns on the visible table. Image open.png is in file details_col.php. [code] /* Add the details image at the start of the display array */ $row[] = ''; [/code] I think i am not calling function fnFormatDetails when i click this image. Version datatables is 1.8.2. [code] function fnFormatDetails ( nTr ) { var aData = oTable.fnGetData( nTr ); var sOut = ' '; sOut += 'Rendering engine:'; sOut += 'Link to source:Could provide a link here'; sOut += 'Extra info:And any further'; sOut += ' '; return sOut; } [/code] Thanks if someone knows what is wrong.
- 26th Feb 2013Failing to reload datatables with updated informationHi Allan, I'm working on a project in which I have to update the dataTable after I have performed some record update. I'm using C# for the backend end I'm getting all json responses properly. Here is how I go about it, please note that the following code is a minified version of the app I'm working on: [code] var oTable, var otherVars; //global vars var app = { getAllData: function() { return $.ajax({ type: "POST", url: "/Services/SerialNumberLookupService.aspx/GetSerialWorkOrder", data: JSON.stringify(serverMethodParamObject), contentType: "application/json; charset=utf-8", dataType: "json" }); }, init: function(config) { var _self = this, deferred = $.Deferred(); //some code... if (typeof oTable !== "undefined" && oTable !== null) { oTable.fnDestroy(); } $.when(_self.getAllData()).done(function (resp) { data = $.parseJSON(resp.d); if ($('.dataTables_filter').length) $('.dataTables_filter').remove(); oTable = $('table.dataContainer').dataTable({ aaData: data, bFilter: true, bInfo: false, bPaginate: true, sPaginationType: "full_numbers", bJQueryUI: true }); //some code... $("#save").on('click', function() { var _self = this; _self.init({/*config parm */}); // reloading the dataTable // more code below }); }; [/code] It reloads the data fine the first time, but the second time I get on the console: Uncaught TypeError: Cannot read property 'nTableWrapper' of null line 4557 Thank you for taking the time to response to this.
- 19th Sep 2012Creating Links Using Database InformationHello, I'm new to using DataTables and I love it! Excellent work :) I'm sorry if this question has been asked before, I'm sure it has, but I couldn't the appropriate link. I need to create links in my table based on the unique ID of each record. For example, I'd like to make a column that displays like this: [code]