How to add custom drop down filter in wordpress WP_List_Table

wordpress

Solution

after struggle of 3-hours after posting question here, i explored the class, and found the solution, so i am sharing information here.

There is a function function extra_tablenav( $which ), I override that function with my function,

function extra_tablenav( $which ) {
    global $wpdb, $testiURL, $tablename, $tablet;
    $move_on_url = '&cat-filter=';
    if ( $which == "top" ){
        ?>
        <div class="alignleft actions bulkactions">
        <?php
        $cats = $wpdb->get_results('select * from '.$tablename.' order by title asc', ARRAY_A);
        if( $cats ){
            ?>
            <select name="cat-filter" class="ewc-filter-cat">
                <option value="">Filter by Category</option>
                <?php
                foreach( $cats as $cat ){
                    $selected = '';
                    if( $_GET['cat-filter'] == $cat['id'] ){
                        $selected = ' selected = "selected"';   
                    }
                    $has_testis = false;
                    $chk_testis = $wpdb->get_row("select id from ".$tablet." where banner_id=".$cat['id'], ARRAY_A);
                    if( $chk_testis['id'] > 0 ){
                ?>
                <option value="<?php echo $move_on_url . $cat['id']; ?>" <?php echo $selected; ?>><?php echo $cat['title']; ?></option>
                <?php   
                    }
                }
                ?>
            </select>
            <?php   
        }
        ?>  
        </div>
        <?php
    }
    if ( $which == "bottom" ){
        //The code that goes after the table is there

    }
}

and then I jumped into function prepare_items() and added a line after query string,

if( $_GET['cat-filter'] > 0 ){
            $query = $query . ' where cat_id=' . $_GET['cat-filter'];   
        }

not finished here, I added some lines of javascript to execute drop down,

$('.ewc-filter-cat').live('change', function(){
    var catFilter = $(this).val();
    if( catFilter != '' ){
        document.location.href = 'admin.php?page=ewc-testimonial'+catFilter;    
    }
});

and its working cool and fine, if anybody need more help then comment here.

Thank you for time.

Problem

I extended class `WP_List_Table` to display listing records of Custom Database Table. Listing is successful but I'm getting mad about how to implement a drop-down filter to filter my custom db table records according to its categories. Please share any code to add drop-down filter to filter my custom database table records. Field name is `cat_id`.

Original source