java - GlazedList - Filter table based on 1 column only -


i'm using glazedlist handling jtables in swing project implemented using mvc pattern. have following code in controller incorporating filtering functionality in table.

    final jtextfield txtfilter = view.gettxtsearch();     filterlist<e> textfilteredsource = new filterlist<e>(model.getdatatablesource(), new textcomponentmatchereditor<e>(txtfilter, new textfilterator<e>() {         public void getfilterstrings(list baselist, e element) {            person p = (person) element;            baselist.add(p.getfirstname());            baselist.add(p.getlastname());            baselist.add(p.getbirthday());            baselist.add(p.getage());            baselist.add(p.getoccupation());         }     }));  model.setdatatablesource(textfilteredsource); 

the above code allows table filter based on data present in whole table. want functionality filters table based on 1 column only. know how accomplish this?

ok who'll encounter same problem, solved myself through experimenting, , found out baselist list of string filterlist filtering job. requirement, added column value need filtered baselist parameter.

the following code filter table based on combobox selected index coming view.

    public void getfilterstrings(list baselist, e element) {        jcombobox cbo = view.getcbosearch();        int selindex = cbo.getselectedindex();        person p = (person) element;         if(selindex == 0)           baselist.add(p.getfirstname());        else if(selindex == 1)           baselist.add(p.getlastname());        else if(selindex == 2)           baselist.add(p.getbirthday());        else if(selindex == 3)           baselist.add(p.getage());        else if(selindex == 4)           baselist.add(p.getoccupation());     } 

Comments

Popular posts from this blog

Change php variable from jquery value using ajax (same page) -

Pull out data related to my apps from Android Play Store and iOS App Store -

How can I fetch data from a web server in an android application? -