Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > Web Development
You last visited: Today at 14:10

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Js Datatable custom Option

Discussion on Js Datatable custom Option within the Web Development forum part of the Coders Den category.

Reply
 
Old   #1
 
MaLLaH95's Avatar
 
elite*gold: 0
Join Date: Dec 2014
Posts: 106
Received Thanks: 16
Js Datatable custom Option

Hallo,

ich habe eine Datatable und diese hat eine zusätzliche Suchfunktion via Option select.

Jetzt wollte ich aber 2 Options einfügen und irgendwie klappt es nicht so ganz

Man sollte die Tabelle nach select_tag filtern können und zusätzlich select_tag2
HTML
Code:
<div class="row">
  <div class="col-md-4 offset-md-4">
  <div class="form-control">
    <label>Filter</label>
    <select id="select_tag" class="form-control">           
    <option value="tag1">tag1</option>
    <option value="tag2">tag2</option>              
</select>
  </div>
  </div>
 
<div class="row">
  <div class="col-md-4 offset-md-4">
  <div class="form-control">
    <label>Filter</label>
    <select id="select_tag2" class="form-control">           
    <option value="de">Deutsch</option>
    <option value="en">English</option>              
</select>
  </div>
  </div>
</div>

<table id="mytable" class="table table-striped table-bordered dt-responsive" width="100%">
    <thead>
        <tr>
            <th>Column1</th>
            <th>Column2</th>
        </tr>
    </thead>
    <tbody>
        <tr data-mytag = "tag1" data-mytag2 = "de">
            <td>1</td>
            <td>German 01</td>
        </tr>
        <tr data-mytag = "tag2" data-mytag2 = "de">
            <td>2</td>
            <td>German 02</td>
        </tr>
        <tr data-mytag = "tag2" data-mytag2 = "en">
              <td>3</td>
              <td>English 01</td>
         </tr>
        <tr data-mytag = "tag1" data-mytag2 = "en">
            <td>4</td>
            <td>English 02</td>
        </tr>
    </tbody>
</table>
Javascript
Code:
var mytable= $('#mytable').DataTable();
$('#select_tag').on('change', function () {
  mytable.draw();
});

$.fn.dataTable.ext.search.push(
     function( settings, searchData, index, rowData, counter ) {
       var row = mytable.row(index).node();
       var filterValue = $(row).data('mytag');
       var e = document.getElementById("select_tag");
       var filter = e.options[e.selectedIndex].value;
       if(filterValue == filter)
          return true;
       
       return false;
 
     }
);
MaLLaH95 is offline  
Old 10/06/2020, 17:52   #2
 
elite*gold: 0
Join Date: Apr 2011
Posts: 363
Received Thanks: 167
You should stick to the api reference:

elmarcia is offline  
Reply


Similar Threads Similar Threads
DataTable.pak
09/28/2013 - Florensia - 3 Replies
Da Florensia Base ja leider geschlossen wurde und ich noch die Dateien auf meinem Lappi habe, habe ich gedacht , wenn jemand dieses Datable error da bekommt, das er dann diese dateien downloaden kann DataTable.apk VT
Florensia Datatable Error
09/25/2013 - Florensia - 0 Replies
Hey ich kriege beim Starten von Florensia diesen Error:florensia datatable error Und danach reagiert das Spiel nicht es gibt einen Fixx dafür allerdings sind die Downloadlinksdown,kann mir jemand sagen wo ich die herbekomme?
Visual Basic - String Split -> Array -> Datatable
09/03/2012 - .NET Languages - 2 Replies
Hallo Leute, ich benötige Hilfe mein Array in eine Datatable zu schreiben Mein Code For Each oFile In oFiles aryTextFile = oFile.Name.Split("_")
[C# Question] DataTable vs. Direct-Access
09/13/2009 - CO2 Programming - 0 Replies
The public release of COEmu v2 reads/writes/updates data in a MySQL database directly. I'd like to know what are the disadvantages of manipulating that data in a DataTable (rather than doing it directly) and then transferring it to the MySQL database. A glaring problem could be that if the programme for whatever reason closes then more data would be lost. Periodic transfers would be done to minimize this lost. Any other problems/suggestions are welcomed.



All times are GMT +1. The time now is 14:10.


Powered by vBulletin®
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2026 elitepvpers All Rights Reserved.