开发者

CFGRID - replace data store or filter on more than one column

开发者 https://www.devze.com 2022-12-30 12:10 出处:网络
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 u

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).开发者_如何学Go. 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?


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


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...

0

精彩评论

暂无评论...
验证码 换一张
取 消