views:

188

answers:

2

ColdFusion 8

I have a cfgrid that that is based on a query. It is not bound to a cfc function because I want a scrolling grid, not a paged grid (you must supply the page number and page size if you use BIND).. I can figure out how to make it filter on one column by using the following code, but I really need to filter on three columns...

grid.getDataSource().filter("OT_MILESTONE",t1);

Adding more to the filter string does not do the trick...it ignores anything more than the first pair of values..

so..I thought if I called a function that passes the three values and returned the query results to me, I could replace the Data Store for the grid..but I cannot figure out the syntax to get it to replace.

The returned variable for the query has the following format:

{"COLUMNS":["SEQ_KEY","ID","OT_MILESTONE"],"DATA":[[63677,"x","y"]]} 

Any ideas?

+1  A: 

have you looked at queryconvertforgrid()?

http://www.cfquickdocs.com/cf9/#queryconvertforgrid

Update: have you looked at these?

http://www.danvega.org/blog/index.cfm/2008/3/10/ColdFusion-8-Grid-Filtering

http://www.coldfusion-ria.com/Blog/index.cfm/2009/1/13/Playing-with-cfgrid--Filter-showhide-Columns-and-using-the-YUI-Buttons-library

http://cfsilence.com/blog/client/index.cfm/2007/8/9/Filtering-Records-In-An-Ajax-Grid

Henry
yes, that was one of my experiments..it requires the page number and pagesize ...so I cannot use it. I tried 'faking it out' by putting 1 for the page and the number of records for the pagesize - but then the grid automatically turns into a huge paged grid.
Casuzen
Answer updated.
Henry
Dan Vega's is where I got the code for the single filter, the other two are using bound grids with page and pagesize... I've been playing with the code here: http://stackoverflow.com/questions/1805954/appending-data-to-gridpanel-in-extjs have parsed the JSON return into the pieces I need, but haven't gotten the store to actually replace yet.
Casuzen
you can ask Dan on twitter if you like. He was the CF8 CFGRID man I tell you. :)
Henry
A: 

after much blood, sweat, tears and swearing..here's the answer, in case anyone else might need to filter a cfgrid by more than one variable:

            var w1 = ColdFusion.getElementValue('wbs');
            var t1 = ColdFusion.getElementValue('task');    
            var p1 = ColdFusion.getElementValue('project');

            grid = ColdFusion.Grid.getGridObject('data');
            store = grid.getDataSource();
            store.clearFilter();
            store.filterBy(function myfilter(record) {
                    var wantit = true;
                        if (trim(w1) != '') {
                            if(record.get('WBS_ID') != w1) {
                                wantit = false;
                        }}
                        if (trim(t1) != '') {
                            if(record.get('OT_MILESTONE') != t1) {
                                wantit = false;
                        }}
                        if (trim(p1) != '') {
                            if(record.get('PROJECT') != p1) {
                                wantit = false;
                        }}

                    return wantit;
                });

            ColdFusion.Grid.refresh('data',false); 

you will need a JS trim function...

Make sure the column names are caps...

Casuzen