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

How to update only orthogonal (but not displayed) data in DataTables?

$
0
0

We can use cell().data() to set cell data. But what if we need to just update orthogonal cell properties, but not main display data, which is rendered in the cell? I.e. we have this data for the cell and we just want to update current_value while keeping display unchanged in the DOM:

"digit": {
    "display": "<select><option selected value=`1`>1</option><option value=`2`>2</option></select>",
    "current_value": "1"
}

My use case is using <select> within a cell — when option changes I want to keep select in place and only change orthogonal data.

I tried cell().invalidate() while adding data- attribute to the DOM element like described here, but it does not seem to work — in the end I have just HTML-contents of the cell in the cell().data() response and orthogonal cell data is gone. I am using ajax data to initially populate the table


FixedHeader appearing below table

$
0
0

Fixed header only appears below my datatable, and only when I resize the window. It seems to be appearing just before the end of the html body. What might be wrong?

Is DeferRender option available for Gridview Databind on ASP.NET ?

$
0
0

I use gridview with large amount of data, then it's too slow rendering for large data, I need to use deferRender and tried but nothing changed, is there another option to use like deferrender ?

DataTable destroy export button generate error.

$
0
0

I want to destroy and reinitialize Table with fixed column and export Buttons.
Console error: Uncaught TypeError: Cannot read property 'node' of undefined dataTables.buttons.js:199.
File dataTables.buttons.js:199.
destroy: function ()
{
// Key event listener
$('body').off( 'keyup.'+this.s.namespace );

    // Individual button destroy (so they can remove their own events if
    // needed
    var buttons = this.s.buttons;
    var i, ien;

    for ( i=0, ien=buttons.length ; i<ien ; i++ ) {
        this.remove( buttons[i].node ); !!!
    }

    // Container
    this.dom.container.remove();

    // Remove from the settings object collection
    var buttonInsts = this.s.dt.settings()[0];

    for ( i=0, ien=buttonInsts.length ; i<ien ; i++ ) {
        if ( buttonInsts.inst === this ) {
            buttonInsts.splice( i, 1 );
            break;
        }
    }

    return this;
},

MY code:
<meta charset="utf-8">
<link rel="shortcut icon" type="image/ico" href="http://www.datatables.net/favicon.ico">
<meta name="viewport" content="initial-scale=1.0, maximum-scale=2.0">
<title>DataTables example - Scroll - horizontal and vertical</title>
<link rel="stylesheet" type="text/css" href="../media/css/jquery.dataTables.css">

<link rel="stylesheet" type="text/css" href="../media/css/fixedColumns.dataTables.css">
<link rel="stylesheet" type="text/css" href="../media/css/buttons.dataTables.css">

<link rel="stylesheet" type="text/css" href="../media/css/shCore.css">
<link rel="stylesheet" type="text/css" href="../media/css/demo.css">


<style type="text/css" class="init">

div.dataTables_wrapper {
    width: 800px;
    margin: 0 auto;

}

</style>
<script type="text/javascript" language="javascript" src="../media/js/jquery-1.12.3.min.js">
</script>
<script type="text/javascript" language="javascript" src="../media/js/jquery.dataTables.js">
</script>
<script type="text/javascript" language="javascript" src="../media/js/dataTables.fixedColumns.js"></script>

<script type="text/javascript" language="javascript" src="../media/js/dataTables.buttons.js">   </script>
<script type="text/javascript" language="javascript" src="../media/js/jszip.min.js">    </script>

<script type="text/javascript" language="javascript" src="../media/js/buttons.print.js">    </script>
<script type="text/javascript" language="javascript" src="../media/js/pdfmake.min.js">  </script>
    <script type="text/javascript" language="javascript" src="../media/js/vfs_fonts.js">    </script>


<script type="text/javascript" language="javascript" src="../media/js/shCore.js"> </script>
<script type="text/javascript" language="javascript" src="../media/js/demo.js">
</script>

var table; $(document).ready(function() { $("#example > tbody").html(""); $("#example > tbody").append("TigerNixonSystem ArchitectEdinburgh612011/04/25$320,8005421t.nixon@datatables.net") $("#example > tbody").append("TigerNixonSystem ArchitectEdinburgh612011/04/25$320,8005421t.nixon@datatables.net") $("#example > tbody").append("TigerNixonSystem ArchitectEdinburgh612011/04/25$320,8005421t.nixon@datatables.net") $("#example > tbody").append("TigerNixonSystem ArchitectEdinburgh612011/04/25$320,8005421t.nixon@datatables.net") $("#example > tbody").append("TigerNixonSystem ArchitectEdinburgh612011/04/25$320,8005421t.nixon@datatables.net") $("#example > tbody").append("TigerNixonSystem ArchitectEdinburgh612011/04/25$320,8005421t.nixon@datatables.net") table = $('#example').DataTable( { dom: 'Bfrtip', buttons: [ 'copy', 'csv', 'excel', 'pdf', 'print' ], scrollY: "300px", scrollX: true, scrollCollapse: true, paging: false, bDestroy: true, fixedColumns: { leftColumns: 1, rightColumns: 0 } } ); } ); var count =0; function test(){ //table.buttons().destroy(); //$(".dt-buttons").remove(); table .clear() .draw(); table.destroy(); count++; $("#example > tbody").append(""+count+"NixonSystem ArchitectEdinburgh612011/04/25$320,8005421t.nixon@datatables.net") table = $('#example').DataTable( { dom: 'Bfrtip', buttons: [ 'copy', 'csv', 'excel', 'pdf', 'print' ], scrollY: "300px", scrollX: true, scrollCollapse: true, paging: false, bDestroy: true, fixedColumns: { leftColumns: 1, rightColumns: 0 } } ); alert("TEst"); //table.cell( 0, 0 ).data( 'New data' ).draw(); //table.fixedColumns().update(); }

</head>
<button onclick="test()" >test</button>
<body class="dt-example">
<div class="container">
<section>
<br>
<table id="example" class="display nowrap" cellspacing="0" width="100%">
<thead>

                <tr>
                    <td>Michael</td>
                    <td>Bruce</td>
                    <td>Javascript Developer</td>
                    <td>Singapore</td>
                    <td>29</td>
                    <td>2011/06/27</td>
                    <td>$183,000</td>
                    <td>5384</td>
                    <td>m.bruce@datatables.net</td>
                </tr>
                <tr>
                    <td>Donna</td>
                    <td>Snider</td>
                    <td>Customer Support</td>
                    <td>New York</td>
                    <td>27</td>
                    <td>2011/01/25</td>
                    <td>$112,000</td>
                    <td>4226</td>
                    <td>d.snider@datatables.net</td>
                </tr>
            </tbody>
        </table>

    </section>
</div>

I need to do 3 click to destroy and reinitialize the table. I have no other errors. If i use only print button works perfectly or if i remove the js libs:
buttons.flash.js
buttons.html5.js

Any help will be appreciated.

Child tables

$
0
0

Is it possible to nest tables in a table. I.e click a link and see another tables sub data. I would like to do this via multiple levels. Also can i click on a row and by clicking that row send the row id to another part of the page section and show a table somewhere else on the page based on that key id

I got data But it will append at second row instead of first row, so it will show no data available

$
0
0

<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title>Customer List</title>
<meta name="viewport" content="initial-scale=1.0,maximum-scale=1.0,user-scalable=no">
<link rel="icon" type="image/ico" href="<?php echo base_url();?>favicon.ico">
<link rel="stylesheet" href="<?php echo base_url();?>bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" href="<?php echo base_url();?>css/elusive/css/elusive-webfont.css">
<link rel="stylesheet" href="<?php echo base_url();?>js/lib/datatables/css/bootstrap.dataTables.css">
<link rel="stylesheet" href="<?php echo base_url();?>js/lib/datatables/extras/TableTools/media/css/TableTools.css">
<link rel="stylesheet" href="<?php echo base_url();?>css/style.css">
<link rel="stylesheet" href="<?php echo base_url();?>css/blue.css" id="theme">
<link rel="stylesheet" href="<?php echo base_url();?>css/fonts.googleapis.css">
</head>
<body>
<!-- main wrapper (without footer) -->
<div id="main-wrapper">
<?php include("header.php");?>
<section id="main_section">
<div class="container-fluid">
<div id="contentwrapper">
<div id="content">
<!-- main content -->
<div class="row-fluid">
<div class="span12">
<div class="box_a">
<div class="box_a_heading"></div>
<div class="box_a_heading"><!--important div to show table sorting text on it--></div>
<div class="box_a_content">
<table id="dt_scroll" class="table table-striped">
<thead>
<tr>
<th>Sr. No.</th>
<th>ecap app id</th>
<th>Customer Name</th>
<th>Customer Contact</th>
<th>Application-ID</th>
<th>File Status</th>
<th>City</th>
<th>Vendor Login Date</th>
<th>Total Amount Applied</th>
<th>Sanctione Date</th>
<th>Loan Amount Sanctioned</th>
<th>Name Of Vendor</th>
<th>Sourcing Channel</th>
</tr>
</thead>
<tbody id="abc">
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
<?php include("sidemenu.php");?>
<div id="footer_space"></div>
</div>
</section>
</div>
<?php include("footer.php");?>
<script src="<?php echo base_url();?>js/jquery.min.js"></script>
<script src="<?php echo base_url();?>js/jquery-migrate-1.2.1.min.js"></script>
<script src="<?php echo base_url();?>bootstrap/js/bootstrap.min.js"></script>
<script src="<?php echo base_url();?>js/jquery.actual.min.js"></script>
<script src="<?php echo base_url();?>js/jquery_cookie.js"></script>
<script src="<?php echo base_url();?>js/jquery.jpanelmenu.js"></script>
<script src="<?php echo base_url();?>js/tinynav.js"></script>
<script src="<?php echo base_url();?>js/hagal_common.js"></script>
<script src="<?php echo base_url();?>js/lib/datatables/jquery.dataTables.min.js"></script>
<script src="<?php echo base_url();?>js/lib/datatables/bootstrap.dataTables.js"></script>
<script src="<?php echo base_url();?>js/pages/hagal_datatables.js"></script>
<script src="<?php echo base_url();?>js/spanbadge.js"></script>
<script>
$(document).ready(function(){
$('#dt_scroll').dataTable();
});

    $(document).ready(function()
    {
        $.ajax({
            url:"<?php echo base_url()?>super_admins/customer_controller/get_customer_list",
            type: "POST",
            dataType: 'json',
            success: function(data)
            {
                    var obj = data;
                     var i;
                            for (i = 0; i < obj.length; i++) {

                                if(i%2 != 0){
                                    var category = '<tr class="odd">'
                                        + '<td class="sorting_1" >' +  obj[i].sr + '</td>'
                                        + '<td>' +  obj[i].mis_no + '</td>'
                                        + '<td>' +  obj[i].customer_name + '</td>'
                                        + '<td>' +  obj[i].mobile1 + '</td>'
                                        + '<td>' +  obj[i].vendor_appli_id + '</td>'
                                        + '<td>' +  obj[i].work_status + '</td>'
                                        + '<td>' +  obj[i].work_city + '</td>'
                                        + '<td>' +  obj[i].vendor_login_date + '</td>'
                                        + '<td>' +  obj[i].total_amount_applied + '</td>'
                                        + '<td>' +  obj[i].sanctioned_declined_date + '</td>'
                                        + '<td>' +  obj[i].loan_amount_sanctioned + '</td>'
                                        + '<td>' +  obj[i].vendor_name + '</td>'
                                        + '<td>' +  obj[i].source_channel + '</td>'
                                        + '</tr>';
                        $("#abc").append(category);
                                }
                                else{
                                    var category = '<tr class="even">'
                                        + '<td class="sorting_1" >' +  obj[i].sr + '</td>'
                                        + '<td>' +  obj[i].mis_no + '</td>'
                                        + '<td>' +  obj[i].customer_name + '</td>'
                                        + '<td>' +  obj[i].mobile1 + '</td>'
                                        + '<td>' +  obj[i].vendor_appli_id + '</td>'
                                        + '<td>' +  obj[i].work_status + '</td>'
                                        + '<td>' +  obj[i].work_city + '</td>'
                                        + '<td>' +  obj[i].vendor_login_date + '</td>'
                                        + '<td>' +  obj[i].total_amount_applied + '</td>'
                                        + '<td>' +  obj[i].sanctioned_declined_date + '</td>'
                                        + '<td>' +  obj[i].loan_amount_sanctioned + '</td>'
                                        + '<td>' +  obj[i].vendor_name + '</td>'
                                        + '<td>' +  obj[i].source_channel + '</td>'
                                        + '</tr>';
                        $("#abc").append(category);
                                }

                                }//for loop

                $('#dt_scroll').dataTable();
            }//success function

        });
    });

    </script>
</body>

</html>

on click on tr

$
0
0

I use link-button in grid-view for display popup appear by using this

 $(function () {
  $('[ID*=lbViewChart]').on('click', function () {
    var row = $(this).closest('tr');
    var Id = row.find('td')[0].firstChild.data;
    var obj = {};
    obj.ID = Id;
    GetData(obj);
    return false;
});
$(function () {
  $('#tabledata tbody').on('click', 'tr', function () {
    var row = $(this);
    var Id = row.find('td')[0].firstChild.data;
    var obj = {};
    obj.ID = Id;
    GetData(obj);
    return false;
});







i fill table through jquery like this
if (final[i] !== null) {
   $("#tabledata").append("<tbody><tr><td>" +
   final[i][0] + "</td> <td>" +
   final[i][1] + "</td> <td>" +
   final[i][2] + "</td> <td>" +
   final[i][3] + "</td> <td>" +
   final[i][4] + "</td></tr></tbody>");
}

table is successfully filled but when i click on row nothing happens

when i click on row nothing happens any solution?

Line break in Excel export

$
0
0

Hello,

I am searching for a solution to create line breaks in an Excel export. Can someone complete my code to replace the '<br>' in my HTML to a line break in Excel? After hours of searching and trying, my hair is start to fall of ;-)

(This code adds '&lt;br&gt;' in Excel instead the line break.)

Thank u very much in advance!

My code:

$( document ).ready(function() {

var fixNewLine = {
        exportOptions: {
            format: {
                body: function ( data, column, row ) {
                    return column === 5 ?
                        data.replace( /<br\s*\/?>/gi, '"'+"\r\n"+'"' ) :
                        data;
                }
            }
        }
    };


    $('#example').DataTable({
        dom: 'Bfrtip',
        buttons:[
            $.extend( true, {}, fixNewLine, {
                extend: 'copyHtml5'
            } ),
            $.extend( true, {}, fixNewLine, {
                extend: 'excelHtml5'
            } ),
            $.extend( true, {}, fixNewLine, {
                extend: 'pdfHtml5'
            } )
        ]

    });
});


How to make 2 changes to text-data when exporting to excel?

$
0
0

Down below is my script to edit data before exporting to excel.
I tried adding a second change which I commented out. This is the one that bugs.
Is there any way to do both these changes to the data before exporting to excel?

I want to create newlines and then remove all remaining excel tags.

var fixNewLine = {
        exportOptions: {
            format: {
                body: function ( data, column, row ) {
                    // Strip $ from salary column to make it numeric
                    return column === 5 ?
                    data.replace( /<br\s*\/?>/ig, "\n"):
                        data;
//                        data.replace( /<.*?>/ig, ""):
//                        data;
                }
            }
        }
    };

Disable Multi-Row Editing for Specific Fields?

$
0
0

Is it possible to disable multi-row edit support only for specific fields? Ideally I'm looking for a way that wouldn't just block the multi-row edit after the user enters data but instead inform the user at the form level that that field is unavailable for multi-row editing (but still available for single-row edits). Does this exist in Editor 1.5.6/DT 1.10.11? Is it planned for a future release?

Thanks!

MySQL database issue

$
0
0

I need help to restore a mysql database. I'm using cpanel and phpmyadmin.I see not restore function in phpmyadmin.

Issue with '_' in @Entity attributs (Java - Spring)

$
0
0

Hi,

I have a problem with DataTable. I have an @Entity(EntityExample) with some properties like:

private String aexample1;
private String bexample2;
private String cexample_ex3;

When I want to display this entity in DataTable, there is no problem, but when I sort with 'cexample_ex3', I have an error like "org.springframework.data.mapping.PropertyReferenceException: No property cexample found for type EntityExample!".

The JS for DataTable for this column is {data : "cexample_ex3"}
How can I resolve this ?

Thank you :) .

Position of the search box.

$
0
0

Hi,
Can you please help me with the position of the search box. I would like to have in the center.
Thanks

dataTables resize height

$
0
0

when I change the dimension of div that contain the dataTable I would to change the height the dataTable, it's scrollY=true.
thanks

Edit array of objects inside another editor

$
0
0

Hi!

I have an array of objects that I'd like to edit, inside another editor.

It's almost the same as the form in this link: https://editor.datatables.net/generator/index

Is there a way to accomplish that using editor's settings? I mean, no adding too much extra js around to make it work. Maybe something like the group of checkboxes work.

Thanks!
Luciano


PM time converted and shown as AM

$
0
0

e.g. 17:00:00 in the DB shows up as 5:00 AM on the editor grid.

further while editing the PM time gets save as AM.

Is this something to do with windows/regional settings?

The online example https://editor.datatables.net/examples/dates/time.html
works right. But, the one downloaded on my machine does NOT?

how to get data from table while click the button at every time

$
0
0

I need to store all required data from server at once and store into the tables.Then i want to get 100 document from every click

DataTable warning: table id="myTable" = request unknown Parameter '0' for row '0'

$
0
0

Dear Prof,
Im new for MVC and jQuery and i learning now.
i already refer many article and also YouTube video. but still i not able to figure out why the error occurred. kindly release me from this issue. some document says have to include table name after column name. etc: (myTable.ContactName) i tried but same error.

Im realy looking for the solution if possible let me know why its happen :)

below image:
my jQuery code and Controler code


@{
ViewBag.Title = "DatatableForm";
}

Part 1 : Implement jQuery DataTable in ASP.Net MVC

">
Employee Name Company Phone Country City Post Code

@Load Datatable css@
<link href="~/Content/DataTable/css/jquery.dataTables.min.css" rel="stylesheet" />
@Load Datatable js@

@section Scripts{
@* *@

<script>
$(document).ready(function() {
$('#myTable').DataTable({
"ajax": {
"url": "/home/loaddata",
"type": "GET",
"datatype": "json"
},
"column": [
{ "data": "ContactName" },
{ "data": "CompanyName" },
{ "data": "Phone" },
{ "data": "Country" },
{ "data": "City" },
{ "data": "PostCode"}
]
});
});
</script>

}

My controler

public ActionResult loaddata()
{
using (var dc = new ScorpiusLearningEntities())
{
var data = dc.Customers.OrderBy(d=> d.CustomerName).ToList();
return Json(new {data}, JsonRequestBehavior.AllowGet);
}

}

Lightbox editing with Bootstrap modal

$
0
0

I've got an editable "pop-up" table I'm using in a Bootstrap modal, but am having difficulty editing data when using the lightbox editor.

While I'm able to alter my select box values, I'm unable to select or edit the text fields.

I thought this may have been a CSS z-index issue but have so far been unable to rectify the problem; I tried changing the div.DTE_Field_InputControl z-index value to a high number but this hasn't helped.

/*Alterations to DataTables Editor Lightbox to layout fields in two columns on pop-out editor window*/
/* https://editor.datatables.net/examples/styling/columns.html */

div.DTE_Body div.DTE_Body_Content div.DTE_Field {
    float: left;
    width: 50%;
    padding: 5px 20px;
    clear: none;
    box-sizing: border-box;
}

div.DTE_Body div.DTE_Form_Content:after {
    content: ' ';
    display: block;
    clear: both;
}

div.DTED_Lightbox_Wrapper {
    left: 1em;
    right: 1em;
    margin-left: auto;
    margin-right: auto;
    width: 75%;
    z-index: 10000;
}

div.DTE_Field_InputControl {
    z-index: 2000050;
}

Select Value Not Updating

$
0
0

Hi All,

I have the following code and it's almost perfect apart from when a user changes the select value, this doesn't reflect in the database. Everything else updates as it should do, can anyone see where I have gone wrong here?

Thanks

$(document).ready(function() {
    editor = new $.fn.dataTable.Editor( {
        ajax: "../../includes/ajax/load_contracts.php",
        table: "#contract",
        idSrc:  'contract.contractID',
        fields: [ {
                label: "Contract Number:",
                name: "contract.contractNumber"
            }, {
                label: "Contract Start:",
                name: "contract.contractStart"
            }, {
                label: "Contract Term:",
                name: "contract.contractTerm"
            }, {
                label: "Fleet:",
                name: "fleet[].fleetID",
                type: "select"
            }
        ]
    });

    $('#contract').DataTable( {
        dom: "Bfrtip",
        ajax: {
            url: "../../includes/ajax/load_contracts.php",
            type: 'POST'
        },
        columns: [
            { data: "contract.contractID" },
            { data: "contract.contractNumber" },
            { data: "contract.contractStart" },
            { data: "contract.contractTerm" },
            { data: "fleet", render: "[, ].name" }
        ],
        select: true,
        buttons: [
            { extend: "create", editor: editor },
            { extend: "edit",   editor: editor },
            { extend: "remove", editor: editor }
        ]
    } );
} );
<?php
  // DataTables PHP library
  include($_SERVER['DOCUMENT_ROOT'] . '/includes/datatables/DataTables.php');

  // Alias Editor classes so they are easy to use
  use
    DataTables\Editor,
    DataTables\Editor\Field,
    DataTables\Editor\Format,
    DataTables\Editor\Mjoin,
    DataTables\Editor\Upload,
    DataTables\Editor\Validate;

  // Build our Editor instance and process the data coming from _POST

  Editor::inst( $db, 'contract', 'contract.contractID' )
  ->fields(
    Field::inst( 'contract.contractID' ),
    Field::inst( 'contract.contractNumber' ),
    Field::inst( 'contract.contractStart' ),
    Field::inst( 'contract.contractTerm' )
  )

  ->join(
      Mjoin::inst( 'fleet' )
        ->link( 'contract.contractID', 'contract_customer.contractID' )
        ->link( 'fleet.fleetID', 'contract_customer.customerID' )

        ->fields(
          Field::inst( 'fleetID' )
            ->options( 'fleet', 'fleetID', 'name' ),
          Field::inst( 'name' )
        )
  )
  ->process( $_POST )
  ->json();
?>
Viewing all 82256 articles
Browse latest View live


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