How to make dropdown list filter for a table using jQuery?

后端 未结 1 1855
死守一世寂寞
死守一世寂寞 2020-12-30 16:51

I want to make dropdown table filter in special columns, for example I want to make a filter for the \"Married\" Column & select yes or or no from the dropdown,this is m

1条回答
  •  清酒与你
    2020-12-30 17:14

    Try this - uses a regex and jQuery filter function to filter the results based on the select list onchange (using an added class to the tr's to control display). This can also be used in a text input version to live filter any of the table rows for any content so that you can type in peoples names etc and get the filter function to show only the matching names.

    I also put an 'all' option in to show all tr's again (effectively removinmg the filter). Note that it simply hides the non-matching rows, meaning that the striped aspect of the table will not necessarily display as desired, but when I implemented something like this - I also added a function that re-striped the table based on the number of rows and odd / even etc AFTER the filter was applied - thereby re-striping the table display.

    
    
    
        
        Filter
    	
    	
    
    
         
        
        
        
    
    
    
    

    0 讨论(0)
提交回复
热议问题