Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

SOLVED: Datatables. Hide / Show multiple rows within loop

Infinity:

This questions targets to Datatables plug-in for JQuery.

I have HTML table with 3 languages en, ru, fr. For example if English language is chosen French and Russian entries should be hidden, if Russian language is chosen then French and English entries should be hidden and so on.

In the HTML table id looks like:


etc_1_en
etc_1_ru
etc_1_fr
etc_2_en
etc_2_ru
etc_2_fr
etc_3_en
etc_3_ru
etc_3_fr
...

But each entry have the same class: row

HTML table like this:



































Header content 1Header content 2
Etc 1Etc 2
Etc 3Etc 4
Etc 5Etc 6
Foo 1Foo 2
Foo 3Foo 4
Foo 5Foo 6


There are 3 buttons with ID like:


btn_id_en
btn_id_ru
btn_id_fr

But each button have the same class: btn

Here is JQuery code:


tbl = $('#myTable').DataTable();
var rows = tbl.rows().data();

// there looping through all entries
rows.each(function (row, index) {
var row = tbl.row(index);
var data = row.data();
var id = row.id();

// there trying to assign each row to child variable (using Datatable)
var child = row.child;

if (/* some conditions */) { // if / else conditions is working, tested with console.log();

// this part not working, something wrong with child maybe
child.show();

} else {

// this part not working, something wrong with child maybe
child.hide();
}
}

row.id() returning correct ID of each row (tested via console.log(id);). Problem is that hide not working. I'm thinking that something wrong with declaring child.

Maybe I have to use remove() instead of hide(), but in this case how could I restore it after another button will be clicked?

Have you any ideas?



Posted in S.E.F
via StackOverflow & StackExchange Atomic Web Robots


This post first appeared on Stack Solved, please read the originial post: here

Share the post

SOLVED: Datatables. Hide / Show multiple rows within loop

×

Subscribe to Stack Solved

Get updates delivered right to your inbox!

Thank you for your subscription

×