Page 1 of 1

How to add drop down list to filters

PostPosted: Sun Apr 13, 2014 2:40 pm
by alxbal
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.

Re: How to add drop down list to filters

PostPosted: Sat Apr 26, 2014 9:04 pm
by alxbal
Would anybody know how to elaborate on this and make the drop down list fill from the database entries?

Re: How to add drop down list to filters

PostPosted: Wed Apr 30, 2014 11:33 am
by jacks9
See my recent post (Apr 29) in the Pro section.