Filtering Rows
Filtering Rows
Hi guys,
I know this has been discussed before but I really just can't seem to get it working. I am trying to create a row filtering system with toggles so that people can filter students, admins and instructors from a contact type list. I am still relatively new to javascript and am just missing something somewhere (maybe a lot somewhere haha).
This is my filter extension:
[code]
$.fn.dataTableExt.afnFiltering.push(
function( oSettings, aData, iDataIndex ) {
if ( oSettings.nTable == document.getElementById( 'reports_tbl' )) {
var row = oSettings.aoData[ iDataIndex ].nTr;
var target_filter = $('.type_filter_button .active').data("show");
var target_id = $('.type_filter_button .active').data("typebutton");
var type_id = +$(row).data("typeid");
if ( target_filter == "all") {
return true;
} else if (target_filter == "approved") {
if ( type_id == target_id) {
return true ;
}
} return false;
} return true;
}
);
[/code]
And this is basically what I'm creating on the page itself
[code]
Administrator
Instructors
Students
All
Hide This
First Name
Last Name
Role
Courses
<?= $object->type_id ?>
data
data
data
data
data
$('.type_filter_button').click(function() {
$(this).addClass('active').siblings().removeClass('active');
});
[/code]
Any help or pointers in the right direction would be greatly greatly appreciated!!!
I know this has been discussed before but I really just can't seem to get it working. I am trying to create a row filtering system with toggles so that people can filter students, admins and instructors from a contact type list. I am still relatively new to javascript and am just missing something somewhere (maybe a lot somewhere haha).
This is my filter extension:
[code]
$.fn.dataTableExt.afnFiltering.push(
function( oSettings, aData, iDataIndex ) {
if ( oSettings.nTable == document.getElementById( 'reports_tbl' )) {
var row = oSettings.aoData[ iDataIndex ].nTr;
var target_filter = $('.type_filter_button .active').data("show");
var target_id = $('.type_filter_button .active').data("typebutton");
var type_id = +$(row).data("typeid");
if ( target_filter == "all") {
return true;
} else if (target_filter == "approved") {
if ( type_id == target_id) {
return true ;
}
} return false;
} return true;
}
);
[/code]
And this is basically what I'm creating on the page itself
[code]
Administrator
Instructors
Students
All
Hide This
First Name
Last Name
Role
Courses
<?= $object->type_id ?>
data
data
data
data
data
$('.type_filter_button').click(function() {
$(this).addClass('active').siblings().removeClass('active');
});
[/code]
Any help or pointers in the right direction would be greatly greatly appreciated!!!
This discussion has been closed.