How to add drop down list to filters

A collection of tutorials and posts that show additional functionality of MATE

Moderator: KarelB

How to add drop down list to filters

Postby alxbal » Sun Apr 13, 2014 2:40 pm

After reading many posts within the forums i was unable to get a simple and easy answer on how to have a drop down list for a filter, so i found by modifying the ajax_table_editor.js file the quickest and easiest so far.
in
Code: Select all
displayFilters: function() {

where
Code: Select all
html += '<input id="'+instanceName+'filter_'+filterCol+'" class="filterInput" filterCol="'+filterCol+'" type="text" style="width: '+inputWidth+'px;" value="'+filterStr+'" onKeyUp="if(' + instanceName + '.enterPressed(event)){' + instanceName + '.handleFilterSearch(this); return false;}" />';


i modified it with this function with an If & else statement to identify which column is being called.
filtercol variable is the name of the column so in my example the column name is "first_name"'

Replace above code with this (statements do not need brackets)
Code: Select all
if(filterCol == "first_name")
                  html += '<select id="'+instanceName+'filter_'+filterCol+'" class="filterInput" filterCol="'+filterCol+'" type="text" value="'+filterStr+'" onchange="'+ instanceName + '.handleFilterSearch(this);"><option></option><option value = "Alex">Alex</option><option value = "John">John</option><option value = "Sarah">Sarah</option></select>';
else
html += '<input id="'+instanceName+'filter_'+filterCol+'" class="filterInput" filterCol="'+filterCol+'" type="text" style="width: '+inputWidth+'px;" value="'+filterStr+'" onKeyUp="if(' + instanceName + '.enterPressed(event)){' + instanceName + '.handleFilterSearch(this); return false;}" />';
                  


The end result is a drop down list for my 'first_name' column and text inputs for the others.
alxbal
 
Posts: 4
Joined: Sun Apr 13, 2014 2:20 pm

Re: How to add drop down list to filters

Postby alxbal » Sat Apr 26, 2014 9:04 pm

Would anybody know how to elaborate on this and make the drop down list fill from the database entries?
alxbal
 
Posts: 4
Joined: Sun Apr 13, 2014 2:20 pm

Re: How to add drop down list to filters

Postby jacks9 » Wed Apr 30, 2014 11:33 am

See my recent post (Apr 29) in the Pro section.
jacks9
 
Posts: 7
Joined: Fri Apr 05, 2013 12:31 pm


Return to How To

Who is online

Users browsing this forum: No registered users and 4 guests

cron