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

Child rows animation problem - slideDown don't work

$
0
0

Hi, I'm trying to implement this https://datatables.net/blog/2014-10-02
to slide down and up with animation by click on table row (not the plus sign as it is in the example)

THE PROBLEM: When I click on table row, the row details (child row) is displayed, but instantly without animation. When I click on row with opened row details, the row details slide up with animation, so sliding up works fine.

This is my code:

function format ( rowData ) {
        console.log(rowData);
    var div = $('<div/>')
        .addClass( 'loading' )
        .text( 'Loading...' );

    $.ajax( {
        url: 'scripts/details.php',
        data: {
            name: rowData[0]
//              'data0': rowData[0],
        },
        dataType: 'json',
        type: 'post',
        success: function ( json ) {
            console.log(json);
            var childTable = '<div id="rowdetails" class="slider">';
.....
.....
</div>


$('#example tbody').on('click', 'tr', function () {
    var tr = $(this).closest('tr');
    var row = table.row( tr );

    if ( row.child.isShown() ) {
        $('div.slider', row.child()).slideUp( function () {
        row.child.hide();
        tr.removeClass('shown');
        } );
    }
    else {
        row.child( format(row.data()), 'no-padding' ).show();
        tr.addClass('shown');
        $('div.slider', row.child()).slideDown();
    }
} );

Thank you


Setting cell class depending on data

$
0
0

Hi,
I want to set initial class on each cells depending on a field in data.
My field is boolean so it's simple processing.

Is it possible?
Thanks

Possible regression in latest version of DataTables?

$
0
0

I have just upgraded to the latest version of DataTables and the associated extensions. I've found that my tables, which should be 100% width, are no longer 100% width, unless the window is narrow enough to force scrolling. I suspect that I am probably misusing DataTables, rather than a bug, but if so what am I doing wrong? Here is a test program below which exhibits the problem when the window is expanded to full screen width. If you uncomment the two script lines in comments to revert to the previous versions I was using and comment out the current versions you will see that it used to work OK.

Campbell

<!DOCTYPE html>
<html>
<head>
    <title></title>
  
  <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/v/dt/dt-1.10.18/datatables.min.css"/>
  <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/fixedcolumns/3.2.5/css/fixedColumns.dataTables.min.css"/>
  
  <style>
    table {
      width: 100%;
      border-collapse: collapse;
    }
    
    th, td {
      text-align: left;
      border: 1px solid red;
      white-space: nowrap;
    }
    
  </style>
  

  <script type="text/javascript" src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
  
  <!-- Used to work OK with these
  <script type="text/javascript" src="https://cdn.datatables.net/v/dt/dt-1.10.9/datatables.min.js"></script>
  <script type="text/javascript" src="https://cdn.datatables.net/fixedcolumns/3.0.3/js/dataTables.fixedColumns.min.js"></script>
  -->
  
  <!-- Doesn't work with these -->
  <script type="text/javascript" src="https://cdn.datatables.net/v/dt/dt-1.10.18/datatables.min.js"></script>
  <script type="text/javascript" src="https://cdn.datatables.net/fixedcolumns/3.2.5/js/dataTables.fixedColumns.min.js"></script>
  
  <script type="text/javascript">
  $(document).ready( function () {
      $('table').DataTable({
          scrollX: '100%',
          fixedColumns: {
              leftColumns: 1
          }
        });
  } );
  </script>
  
</head>

<body>

<table>
  <thead>
    <tr><th>Name</th><th>Role</th><th>Office</th><th>Notes</th></tr>
  </thead>
  <tbody>
    <tr><td>John Smith</td><td>Managing director</td><td>San Francisco</td><td>ggggb jhjjhjh fgfff</td></tr>
  </tbody>
</table>

</body>
</html>

How do we get multi-column filtering and multi-column sorting order working together

$
0
0

Hi
Ive tried to do this first in 2015 and having just returned to datatables find its still not working as expected. It appears that when clicking filter boxes at the top of each column it triggers the column sorting. From my uploaded files you can see i have used two table head rows; one for the filter text boxes and the other for the standard table headers.

This i thought would solve things but i still have the same issue only now filtering is ignored. Using a single header row puts us back to square one; clicking a filter box sorts the column ...doh!! changing the order of the header rows does creates the same issue. Ive given the header row with the filter input boxes an id so we can target them in the js - it all seems good but just doesn't work. We tried the, 'orderCellsTop' set to true and false and remove it altogether, nothing seems to help.

The way we originally tried (with a single header row) the text boxes replace the header titles and the title text becomes the textbox placeholder text -although not ideal we cant even get this to solve the issue - clicking the text box ALWAYS 'sorts' the column. Our client does NOT want this to happen!! Is my code right or am i missing something here. Vv frustrating ... feel like ive been at this issue without a break SINCE 2015!

See image here:

Code:

HTML
----
                  
  <table id="OfficePropertyOverview" class="table table-striped row-border order-column nowrap" cellspacing="0" width="100%">
        <thead>
        <tr id="filterboxrow">
            <th>ID</th>
            <th>Landlord</th>       
            <th>Manager</th>                    
            <th>Tenant</th>
        </tr>
        <tr>
            <th>ID</th>
            <th>Landlord</th>       
            <th>Manager</th>                    
            <th>Tenant</th>
        </tr>
        </thead>
        <tbody>
        
            ( removed for brevity )
            
        </tbody>
        <tfoot>
            <tr>
                <th>ID</th>
                <th>Landlord</th>       
                <th>Manager</th>                    
                <th>Tenant</th>
            </tr>
        </tfoot>
  </table>
                      
                      
Js /JQuery
----------
    // Init Plugin : Bootstrap Datatables :
    var dTblOverview = $('#OfficePropertyOverview').DataTable(
    {
          'paging'         : true,
          'lengthChange'   : true,
          'searching'      : true,
          'ordering'       : true,
          'info'           : true,
          'autoWidth'      : true,
          'orderCellsTop'  : false,
          
          'columnDefs'     : [
                {
                    "targets"    : [ 0 ],
                    "visible"    : false,
                    "searchable" : false
                },
                {
                    "targets"   : [ 1 ],
                    "visible"   : false
                }
          ]
      
    });
    
    
    

    // Add Multi-Column Filtering To DBOverview Datatable
    $('#OfficePropertyOverview thead tr#filterboxrow th').each(function (){

            var title = $('#OfficePropertyOverview thead tr#filterboxrow th').eq( $(this).index() ).text();
            
            $(this).html('<input type="text" class="form-control" placeholder="filter by ' + title + '" />')
                   .css('padding-left','4px');
    });

    



    
    // Apply the search :
    dTblOverview.columns().eq(0).each(function(colIdx)
    {
          $('input', dTblOverview.column(colIdx).header()).on('keyup change', function()
          {
              dTblOverview
                .column( $(this).parent().index()+':visible' )
                .search( this.value )
                .draw();        
          });
    });

How do you get the cell contents based on a unique row id, (record primary key) and column index

$
0
0

Hi,
Most examples show how to use the row number but not a unique primary-key which in my case is a hidden column (column one). Using row number is only useful if you're not using paging since row 5 page 1 is not the same content as row 5 page 12. Also my column titles were hard-coded into the tables <th> so datatables probably doesn't know about them programmatically so column index would probably be wiser.

cheers

RowGroup custom rendering and data source change event combined?

$
0
0

Hi all together,

I combined the custom rendering and the Data source change event examples from this page: https://datatables.net/extensions/rowgroup/examples/

Instead of average salary in the custom rendering example, I used the sum() function to have the sum of salary for each city.

I now need to have a sort option which will sort the groups using the summed up value. When I now click on the last column the single elements in each city will be ordered, but I need the whole groups ordered using the summed up values.

So, e.g. London is the city with the highest over all salaries, the "London group" should be up, next the second highest salary group and so on.

This is my current script: https://pastebin.com/KkwYcmNG

Hope you can help me out here! I tried to built an example in jsfiddle, but I wasn't able to get the custom rendering example running on jsfiddle. If you have a jsfiddle link with this example running I am happy to add all further details of my code.

Thank you so much!

Collapse / Expand Click Groups

$
0
0

Hi all together,

https://datatables.net/extensions/rowgroup/examples/initialisation/customRow.html

I like to have a possibility to click on the group name like "Averages for Edinburgh" and the group should expand/collapse. Per default when loading the site, the group should be collapsed.

For doing that, I also found this thread here, where redwall was able to embed such a function for his DataTable:
https://datatables.net/forums/discussion/comment/61474/#Comment_61474

But my Javascript skills are less than available :)

Would someone of you be so kind and help me out here? How can I reach the above described functionality on the basic example of "Custom row rendering / aggregates"?

Thank you for your help!!

intervention in new records.

$
0
0

Hi,
i use simple datatable.
My need to interfere with javascript into a text field in the new registration process.

how to do?

Best Regards.


How do you display a form field by default?

$
0
0

What I want to be able to do is when the table is displayed, have one of the fields show as an empty text input. I don't want the user to have to click on it, it should just be editable by default like this:

I have tried to use a form field in the cell, but when the user changes a value and I try to update the data cache values programmatically on keyup (which I need to do to be able to access the value later) using:

$(element).on('keyup', function () {
        var cell = table.cell(element);
        cell.data($("input.withdrawal-amount-value", this).val());
});

DataTables overwrites the form field with the cell's value and clears out my form field. The alternative is to use the DataTables Editor plugin, but all of the examples I've found assume there needs to be some action done by the user (clicking on the row, clicking on an edit button, etc.) I just want a simple form field. Is there a way to do this in either DataTables or the Editor plugin? This seems like a really simple thing...

Need Help Getting Started with Editor

$
0
0

I have an existing DataTable that works fine. I am now attempting to implement Editor but get error:
DataTables warning: table id=example - Requested unknown parameter 'id' for row 0, column 0. For more information about this error, please see http://datatables.net/tn/4.
I've included my page and code below.

Have not been able to figure this one out.

<!doctype html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>DataTables Editor - tblGOP</title>
<link rel="stylesheet" type="text/css" href="../datatables/datatables.min.css">
<link rel="stylesheet" type="text/css" href="../datatables/generator-base.css">
<link rel="stylesheet" type="text/css" href="../datatables/Editor-1.8.0/css/editor.dataTables.min.css">
<script type="text/javascript" charset="utf-8" src="../datatables/datatables.min.js"></script>
<script type="text/javascript" charset="utf-8" src="../datatables/Editor-1.8.0/js/dataTables.editor.min.js"></script>
<script type="text/javascript" charset="utf-8" src="js/GOP.js"></script>
</head>
<body class="dataTables">
<div class="container">
<div class="row">
<div class="col-12">
<header class="text-center mb-4">
<h2 class="h2 g-color-black g-font-weight-600">GOP Reviews (QA)</h2>
</header>
<div class="table-responsive m-t-40">
<table id="example" class="display nowrap table table-hover table-striped table-bordered" cellspacing="0" width="100%">
<thead>
<tr>
<th>ID</th>
<th>Number</th>
<th>Subject</th>
<th>Revision</th>
<th>Review Due Date</th>
</tr>
</thead>
<tfoot>
<tr>
<th>ID</th>
<th>Number</th>
<th>Subject</th>
<th>Revision</th>
<th>Review Due Date</th>
</tr>
</tfoot>
</table>
</div>
</div>
</div>
</div>
</body>

</html>

var editor; // use a global for the submit and return data rendering in the examples

$(document).ready(function() {
editor = new $.fn.dataTable.Editor( {
ajax: "../GOPA.asp",
table: "#example",
fields: [ {
label: "ID",
name: "id"
}, {
label: "Number",
name: "number"
}, {
label: "Subject:",
name: "subject"
}, {
label: "Revision:",
name: "revision"
}, {
label: "Review Due Date:",
name: "review_due_date"
}
]
} );

$('#example').DataTable( {
    dom: "Bfrtip",
    ajax: "../GOPA.asp",
    columns: [
        { data: "id" },
        { data: "number" },
        { data: "subject" },
        { data: "revision" },
        { data: "review_due_date" }
    ],
    select: true,
    buttons: [
        { extend: "create", editor: editor },
        { extend: "edit",   editor: editor },
        { extend: "remove", editor: editor }
    ]
} );

} );

{"data" : [["1","SA-101","Document/Revision Review/Approval Procedures","A","July"],["2","SA-102","Quality Document Style Guide","A","July"],["3","SA-103","Corrosion Prevention and Control Program","C","November"],["4","SA-104","Tool Control Procedures","D","April"],["5","SA-105","Maintenance Control","C","December"],["6","SA-106","Individual Material Readiness list Program","C","December"],["7","SA-107","Gas Turbine Engine Test System and Certification","D","June"],["8","SA-108","Electrostatic Discharge (ESD)","C","December"],["9","SA-109","Central Technical Publication Library (CTPL)","D","January"],["10","SA-110","Naval Aviation Maintenance Discrepancy Reporting Program","C","January"],["11","SA-111","Logs and Records/Technical Directive Compliance","C","January"],["12","SA-112","Foreign Object Damage Prevention Program","C","February"],["13","SA-113","Quality Assurance Audit","F","June"],["14","SA-114","Maintenance Safety Program","B","February"],["15","SA-115","Battery Maintenance Safety","C","February"],["16","SA-116","Weight Handling Program","D","March"],["17","SA-117","Ordnance Qualification Certification Program","C","March"],["18","SA-118","Maintenance Training Program","F","May"],["19","SA-119","GSE, GSE SEPMS, SE Training & Licensing, SE Misuse and Abuse","C","March"],["20","SA-121","Hazardous Material Control and Management","C","April"],["21","SA-122","Metrology and Calibration","C","June"],["22","SA-123","Fuel System Maintenance Procedures","D","April"],["23","SA-124","Safe for Flight","B","May"],["24","SA-125","Fuel Surveillance","E","May"],["25","SA-126","Tire and Wheel Maintenance Safety Procedures","C","April"],["26","SA-127","Quality Assurance Procedures","D","July"],["27","SA-128","Engine Turn-up and Licensing Program","C","July"]]}

Datatables & Custombox

$
0
0

Would there be any way for me to use Custombox when displaying the modal window that appears when clicking the Edit button?

            var modal = new Custombox.modal({
                content: {
                    effect: 'blur',
                    target: '.DTE_Action_Edit'
                },
                loader: {
                    active: false
                }
            });
            modal.open();

It would style the modal (the way it loads) to match all my existing ones.

I thought maybe I could fire the above script as soon as the Edit modal appears, but the following fires before the modal is created:

editor.on( 'initEdit', function ( e, node, data, items, type ) {
    if (type=="main") {
            var modal = new Custombox.modal({
                content: {
                    effect: 'blur',
                    target: '.DTE_Action_Edit'
                },
                loader: {
                    active: false
                }
            });
            modal.open();
    }
} );

Update running totals in column on filter event

$
0
0

I have a column in a table that calculates a running total in a table:

"render": function ( data, type, row, meta ) {
if (meta.row == 0) {
requestedRunningTotal = Number(row[meta.col - 1]);
} else {
requestedRunningTotal = requestedRunningTotal + Number(row[meta.col - 1]);
}

return requestedRunningTotal;

}

It works fine but does not recompute if the table is filtered (values being filtered are in another column). Is there a way to cause the column or cells to recompute using the displayed filtered rows, i.e., show the running total of the filtered values?

Issue with download

$
0
0

Just used https://datatables.net/download/ and the download tab to get DataTables.zip

Unzipped and used ;

<link rel="stylesheet" type="text/css" href="DataTables/datatables.min.css"/>
<script type="text/javascript" src="DataTables/datatables.min.js"></script>

as indicated but got table with incomplete formatting ;

when I use

<link rel="stylesheet" type="text/css" href="./DataTables/DataTables-1.10.18/css/jquery.dataTables.css">

instead, I get the expected/desired result ;

full html failing ;

<html>
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0,minimal-ui=1,user-scalable=no">         
        <script
              src="https://code.jquery.com/jquery-3.3.1.min.js"
              integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
                          crossorigin="anonymous">                              
        </script>
        <link rel="stylesheet" type="text/css" href="./DataTables/datatables.min.css"/>
        <script type="text/javascript" src="./DataTables/datatables.min.js"></script>
    </head>
    <body>
        <table id="resultsTable" class="display">
            <thead>
                <tr>
                    <th>Column 1</th>
                    <th>Column 2</th>
                    <th>Column 3</th>
                    <th>Column 4</th>                            
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td>Row 1 Data 1</td>
                    <td>Row 1 Data 2</td>
                    <td>Row 1 Data 3</td>
                    <td>Row 1 Data 4</td>                            
                </tr>
                <tr>
                    <td>Row 2 Data 1</td>
                    <td>Row 2 Data 2</td>
                    <td>Row 2 Data 3</td>
                    <td>Row 2 Data 4</td>                            
                </tr>
            </tbody>
        </table>
        <script>
            $(document).ready( function () {
                $('#resultsTable').DataTable();
            } );            
        </script>
    </body>
</html>

Windows 10, latest Firefox - no errors reported in developer console.

full html success ;

<html>
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0,minimal-ui=1,user-scalable=no">         
        <script
              src="https://code.jquery.com/jquery-3.3.1.min.js"
              integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
                          crossorigin="anonymous">                              
        </script>
        <link rel="stylesheet" type="text/css" href="./DataTables/DataTables-1.10.18/css/jquery.dataTables.css">`
        <script type="text/javascript" src="./DataTables/datatables.min.js"></script>
    </head>
    <body>
        <table id="resultsTable" class="display">
            <thead>
                <tr>
                    <th>Column 1</th>
                    <th>Column 2</th>
                    <th>Column 3</th>
                    <th>Column 4</th>                            
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td>Row 1 Data 1</td>
                    <td>Row 1 Data 2</td>
                    <td>Row 1 Data 3</td>
                    <td>Row 1 Data 4</td>                            
                </tr>
                <tr>
                    <td>Row 2 Data 1</td>
                    <td>Row 2 Data 2</td>
                    <td>Row 2 Data 3</td>
                    <td>Row 2 Data 4</td>                            
                </tr>
            </tbody>
        </table>
        <script>
            $(document).ready( function () {
                $('#resultsTable').DataTable();
            } );            
        </script>
    </body>
</html>

Is there any way to disable Editor form buttons?

$
0
0

I have the following code, but want different 'edit' buttons to be desensitized based on values within the form fields. Is this possible? I don't see any way to desensitize a button on a form in the button options, buttons api, etc.

Note: I'd like the buttons to be sensitized / desensitized in real time depending on current contents of the fields which are being changed by the user.

    editor.on('open', function( e, mode, action ) {
        // set buttons for create
        if ( action == 'create' ) {
            this.buttons( 'Create' );

        // set buttons for edit
        } else if ( action == 'edit' ) {
            this.buttons([
                    {
                        text: 'Resend Contract',
                        action: function () {
                            this.submit(null, null function(data) {
                                data.addlaction = 'resendcontract';
                            });
                        }
                    },
                    {
                        text: 'Mark Invoice Sent',
                        action: function () {
                            this.field( 'invoiceSentDate' ).set( currentdate() );
                            this.submit();
                        }
                    },
                    {
                        text: 'Mark as Paid',
                        action: function () {
                            this.field( 'paymentRecdDate' ).set( currentdate() );
                            this.submit();
                        }
                    },
                    {
                        text: 'Update',
                        action: function () {
                            this.submit();
                        }
                    },
                    {
                        text: 'Update and Send Contract',
                        action: function () {
                            this.submit(null, null, function(data) {
                                data.addlaction = 'sendcontract';
                            });
                        }
                    },

                ]);

        // set buttons for remove (only other choice)
        } else {
            this.buttons( 'Delete' );
        }

        return true;
    });

Highlight an entry in row if contains pattern

$
0
0

Hi,
New to DataTables so please pardon if a re-post.
Is it possible to highlight an entry (either bold or different color) in a row if it contains a pattern? Eg.,
Make the 3rd entry bold if it contains a 'G'.
T/G G/G **A/G** NA A/A NA

To take it further, is it possible to make only 'G' appear in bold (and not 'A')?
T/G G/G A/**G** NA A/A NA
Thanks so much!


field processing indicator puzzle

$
0
0

I am wondering whether there might be a conflict between having bootstrap loaded and using the default display controller (lightbox). The page was previously developed without bootstrap styles, works without problems without bootstrap, and I do not want to change the current setup as lightbox is fine and looks good.

The problem I am running into is that for some strange reason, the field processing indicator for one of the fields is active when a record is opened in editor. The field, that the field processing indicator is active for, is the one field with a dependency.

I was able to turn the field processing indicator off (see below), but I am wondering why I am encountering this problem.

Mainly I want to make sure that there is no bigger problem that I should be aware of. Is there a list of known issues relating to loading bootstrap and using the lightbox display controller?

Thank you for your kind feedback,
Beate

editor.dependent( 'resolve', function ( val,data ) {
   if (data.row.resolve == "Y") return {
        messages: {'resolve':'<span class="spit">'+data.row.resolvestatus+'</span>'}
   };
    /* get rid of field processing indicators! */
    var prcssInds=$('.DTE_Processing_Indicator');
    for (var i=1; i<prcssInds.length; i++) {
        if (prcssInds[i].outerHTML.indexOf("field-processing") >= 0) {
            prcssInds[i].style.display="none";
        }
    }
});

Click and drag to sort rows?

$
0
0

Let's say I have two rows in a table:

| Order | Name     |
--------------------
| 1     | Bob Dole |
| 2     | Joe John |

What I'm looking for is a way to click on the 2nd row, and drag it over the first row, which would then update both values in the Order column to now look like this:

| Order | Name     |
--------------------
| 1     | Joe John |
| 2     | Bob Dole |

If this isn't possible, I suppose just editing the field would work, if that was possible as well?

pass id array to a php file of selected rows over all pages

$
0
0

I am using datatables.net with this checkbox plugin: https://www.gyrocode.com/projects/jquery-datatables-checkboxes/ and this file structure https://www.sitepoint.com/creating-a-scrud-system-using-jquery-json-and-datatables/
So what I need now are some tiny code snippets in a data.php file and in the webapp.js via jquery that perform some specific mysql actions FOR ALL SELECTRED ROWS OVER ALL PAGES after pressing different submit buttons.
When you press the main drop down menu („Mass Select Operations“) on my live example page http://mydigital.school/mtgtreasure/ you will find all the specific submit buttons on the right, with the specific actions on the left.
So the first one should update the value of the mysql column „forsale“ in the mysql table to the value 1 after pressing it for ALL rows that have a selected checkbox threw all pages.

my datatable structure:
var table_cards = $('#table_cards').dataTable({
"ajax": "data.php?job=get_cards",
"columns": [
{ "data": "checkboxes" },
{ "data": "forsale" },
{ "data": "quantity" },
{ "data": "cardname", "sClass": "cardname" },
{ "data": "edition" },
{ "data": "editionicon"},
{ "data": "price", "sClass": "integer"},
{ "data": "pricechange", "sClass": "integer"},
{ "data": "sellingprice", "sClass": "integer"},
{ "data": "cond"},
{ "data": "cardlanguage"},
{ "data": "foil" },
{ "data": "note" },
{ "data": "functions", "sClass": "functions" }
],

    "aoColumnDefs": [

      {
            'targets': 0,
            'orderable': false,
            'render': function(data, type, row, meta){
               if(type === 'display'){
                  data = '<div class="checkbox"><input type="checkbox" class="dt-checkboxes"><label></label></div>';
               }

               return data;
            },
        'checkboxes': {
               'selectRow': true,
               'selectAllRender': '<div class="checkbox"><input type="checkbox" class="dt-checkboxes"><label></label></div>'
            }

      },

      { "bSortable": false, "aTargets": [-1] }
    ],
    "select":  "multi",
    'order': [[3, 'asc']], // sortiert nach der vierten Spalte - Kartennamen.

    "lengthMenu": [[10, 25, 50, 100, -1], [10, 25, 50, 100, "All"]],
    "oLanguage": {
      "sSearch": "<label id='has-tt-label' for='has-tt' title='Some <b>great</b> input!'>Search: </label>", //search

      "oPaginate": {
        "sFirst":       " ",
        "sPrevious":    " ",
        "sNext":        " ",
        "sLast":        " ",
      },
      "sLengthMenu":    "Records per page: _MENU_",
      "sInfo":          "Total of _TOTAL_ records (showing _START_ to _END_)",
      "sInfoFiltered":  "(filtered from _MAX_ total records)"
    }


  });

I tried to do it with the following code in the webapp.js to test it with a single mysql change (the button id is mass_putonsale2):
$(document).on('submit','#mass_putonsale2', function(e){
e.preventDefault();
show_loading_message();
var form = this;

      var rows_selected = table_cards.column(0).checkboxes.selected();

      // Iterate over all selected checkboxes
      $.each(rows_selected, function(index, rowId){
         // Create a hidden element 
         $(form).append(
             $('<input>')
                .attr('type', 'hidden')
                .attr('name', 'id[]')
                .val(rowId)
               );
            }
      );

    var form_data_putonsale = $(form).serialize();
    var request = $.ajax({
      url:          'data.php?job=mass_putonsale',
      cache:        false,
      data:         form_data_putonsale,
      dataType:     'json',
      contentType:  'application/json; charset=utf-8',
      type:         'get'
    });
    hide_loading_message();

and with the following code in data.php:
elseif ($job == 'mass_putonsale'){

     $query = "UPDATE cards SET forsale = 1 WHERE id = '";  mysqli_real_escape_string($conn,$_GET['id'][0]) ."'";
     $query  = mysqli_query($conn, $query);
  }

Need to add dropdown as a column loading static data

$
0
0

I am new to data tables.I would like to add a dropdown with two values open,close and based on selected values the following changes will happen.Please help me with this

Datatable with checkbox, how to get IDs ?

Viewing all 79535 articles
Browse latest View live




Latest Images