Question

Cold Fusion CFGRID and page argument

Asked by: stucal

Hi
Is it possible to manupulate the cfgridpage argument to display the 5th page of a 10 page grid on first load and still have full paging working. thanks

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2009-11-05 at 16:02:18ID24876606
Topic

Cold Fusion Markup Language

Participating Experts
1
Points
500
Comments
16

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. indexing in cold fusion
    i have made a search interface in cold fusion and i want that my search should display only 10 results per page and the rest of the results on the next page.can anyone please help me out.
  2. Cold Fusion Grids
    Can a select statement be nested inside a Cold Fusion Grid?

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: azadisaryevPosted on 2009-11-05 at 17:02:34ID: 25755843

it's definitaly possible - after all, it's CF! :)

it involves a bit of javascript and ajaxonload() cf function.

pay attention to comments in js code below!

1) add <cfajaximport/> at the top of your page to ensure all required js libraries are properly loaded. this is important.

2) add this js to the <head> section of your page:

<script type="text/javascript">
var startPage = 4; //the page you want to reset your cfgrid to.
//IMPORTANT: the grid's page index is 0-based!
//so if you want to start at page 5 you have to set startPage to 4 above!!!
var pageSize = 10; // this should equal the value of pagesize attribute of your cfgrid!!!
setGridToPage = function() {
  mygrid = ColdFusion.Grid.getGridObject('mygrid1'); // get grid object.
  //IMPORTANT: change mygrid1 above to your cfgrid's actual name (the name attribute of cfgrid)
  ds = mygrid.getDataSource(); //get the grid's data store
  ds.load({params:{start:startPage*pageSize, limit:pageSize}}); //reload data store at page 5
  //technically, we are not setting a page number - we are reloading data store to show records from page 5
  cm = mygrid.getColumnModel(); //get grid's column model
  mygrid.reconfigure(ds,cm); //reconfigure the grid to show page 5
}
</script>

3) add this as the last line before the closing </body> tag in your page:
<cfset ajaxonload('setGridToPage')>

voila!

Azadi

 

by: stucalPosted on 2009-11-06 at 00:01:23ID: 25757412

Thanks Azadi, i have tried adding this to my code but no joy still displays the first page, so i must have missed something. my code is attached.

basically i have 2 bound selects which control the returned data in the grid.

I looked at the page source in the browser and cant seem to find the ajax  reload at the bottom, i have attached that aswell

stu

cfm source--------------------------------------------------------
 
<cfajaximport/>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Auctioneer Loader</title>
<script type="text/javascript">
var startPage = 4; //the page you want to reset your cfgrid to.
//IMPORTANT: the grid's page index is 0-based!
//so if you want to start at page 5 you have to set startPage to 4 above!!!
var pageSize = 10; // this should equal the value of pagesize attribute of your cfgrid!!!
setGridToPage = function() {
  mygrid = ColdFusion.Grid.getGridObject('Auctioneers'); // get grid object. 
  //IMPORTANT: change mygrid1 above to your cfgrid's actual name (the name attribute of cfgrid)
  ds = mygrid.getDataSource(); //get the grid's data store
  ds.load({params:{start:startPage*pageSize, limit:pageSize}}); //reload data store at page 5
  //technically, we are not setting a page number - we are reloading data store to show records from page 5
  cm = mygrid.getColumnModel(); //get grid's column model
  mygrid.reconfigure(ds,cm); //reconfigure the grid to show page 5
}
</script>
 
</head>
<body bgcolor="#ffffff">
<link href="/css/styles.css" rel="stylesheet" type="text/css">
<cfform method="get" name="myform" preloader="no" id="myformid">
<cfinput type="hidden" name="selprov" value="#url.selprov#">
<cfinput type="hidden" name="seldisp" value="#url.seldisp#">
 
	<table width="675" border="0" cellpadding="0" cellspacing="0">
		<tr>
			<td width="140" class="bodytextbold">Select by Province:</td>
			<td width="140" class="bodytext"><cfselect name="province"
					bind="cfc:Auctioneers.getProvinces({selprov})"
					bindonload="true" /></td>
			<td width="140" class="bodytextbold">Select by Discipline:</td>
			<td width="220" class="bodytexttext"><cfselect name="discipline"
					bind="cfc:Auctioneers.getDisciplines({seldisp})"
					bindonload="true" /></td>			
		</tr>
			<td></td>
		<tr>
		</tr>
	</table>
	<br />
	   <cfgrid name="Auctioneers" bindonload="true" appendkey="yes" griddataalign="left" gridlines="yes" rowheaderalign="left" colheaderalign="left" bgcolor="##bbbbbb" selectcolor="##bbbbbb" selectmode="browse" enabled="yes" visible="yes"
            format="html"
            bind="cfc:Auctioneers.getAuctioneers({cfgridpage},
                                        {cfgridpagesize},
                                        {cfgridsortcolumn},
                                        {cfgridsortdirection},
										{province},
										{discipline})"
            pagesize="10" preservepageonsort="false"
            striperows="yes" selectonload="false" textcolor="##000000" autowidth="false">
        <cfgridcolumn name="auctioneer_1" header="Auctioneer" headeralign="left" dataalign="left" width="225" bold="no" italic="no" select="no" display="yes" headerbold="yes" headeritalic="no" textcolor="##000000"/>
		<cfgridcolumn name="auctioneer_sel" header="" headeralign="left" dataalign="center" width="80" bold="no" italic="no" select="no" display="yes" headerbold="yes" headeritalic="no" textcolor="##000000"/>
        <cfgridcolumn name="auctioneer_2" header="Contact Details" headeralign="left" dataalign="left" width="195" bold="no" italic="no" select="no" display="yes" headerbold="yes" headeritalic="no"/>
		<cfgridcolumn name="auctioneer_3" header="Disciplines" headeralign="left" dataalign="left" width="172" bold="no" italic="no" select="no" display="yes" headerbold="yes" headeritalic="no" textcolor="##000000"/>
    </cfgrid>
</cfform>
<cfset ajaxonload('setGridToPage')>
</body>
</html>
 
 
 
source in browser -----------------------------------------------
 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><script type="text/javascript">_cf_loadingtexthtml="<img alt=' ' src='/CFIDE/scripts/ajax/resources/cf/images/loading.gif'/>";
_cf_contextpath="";
_cf_ajaxscriptsrc="/CFIDE/scripts/ajax";
_cf_jsonprefix='//';
</script><script type="text/javascript" src="/CFIDE/scripts/ajax/messages/cfmessage.js"></script>
<script type="text/javascript" src="/CFIDE/scripts/ajax/package/cfajax.js"></script>
<script type="text/javascript" src="/CFIDE/scripts/ajax/yui/yahoo-dom-event/yahoo-dom-event.js"></script>
<script type="text/javascript" src="/CFIDE/scripts/ajax/yui/animation/animation-min.js"></script>
<script type="text/javascript" src="/CFIDE/scripts/ajax/ext/adapter/yui/ext-yui-adapter.js"></script>
<script type="text/javascript" src="/CFIDE/scripts/ajax/ext/ext-core.js"></script>
<script type="text/javascript" src="/CFIDE/scripts/ajax/ext/package/util.js"></script>
<script type="text/javascript" src="/CFIDE/scripts/ajax/ext/package/widget-core.js"></script>
<script type="text/javascript" src="/CFIDE/scripts/ajax/ext/package/data/data.js"></script>
<script type="text/javascript" src="/CFIDE/scripts/ajax/ext/package/dragdrop/dragdrop.js"></script>
<script type="text/javascript" src="/CFIDE/scripts/ajax/ext/package/form/form.js"></script>
<script type="text/javascript" src="/CFIDE/scripts/ajax/ext/package/button/button.js"></script>
<script type="text/javascript" src="/CFIDE/scripts/ajax/ext/source/widgets/View.js"></script>
<script type="text/javascript" src="/CFIDE/scripts/ajax/ext/source/widgets/MenuButton.js"></script>
<script type="text/javascript" src="/CFIDE/scripts/ajax/ext/package/toolbar/toolbar.js"></script>
<script type="text/javascript" src="/CFIDE/scripts/ajax/ext/package/grid/grid.js"></script>
<script type="text/javascript" src="/CFIDE/scripts/ajax/ext/package/grid/edit-grid.js"></script>
<script type="text/javascript" src="/CFIDE/scripts/ajax/package/cfgrid.js"></script>
<link rel="stylesheet" type="text/css" href="/CFIDE/scripts/ajax/resources/ext/css/ext-all.css" />
<link rel="stylesheet" type="text/css" href="/CFIDE/scripts/ajax/resources/cf/cf.css" />
<script type="text/javascript" src="/CFIDE/scripts/cfform.js"></script>
<script type="text/javascript" src="/CFIDE/scripts/masks.js"></script>
 
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Auctioneer Loader</title>
<script type="text/javascript">
var startPage = 4; //the page you want to reset your cfgrid to.
//IMPORTANT: the grid's page index is 0-based!
//so if you want to start at page 5 you have to set startPage to 4 above!!!
var pageSize = 10; // this should equal the value of pagesize attribute of your cfgrid!!!
setGridToPage = function() {
  mygrid = ColdFusion.Grid.getGridObject('Auctioneers'); // get grid object. 
  //IMPORTANT: change mygrid1 above to your cfgrid's actual name (the name attribute of cfgrid)
  ds = mygrid.getDataSource(); //get the grid's data store
  ds.load({params:{start:startPage*pageSize, limit:pageSize}}); //reload data store at page 5
  //technically, we are not setting a page number - we are reloading data store to show records from page 5
  cm = mygrid.getColumnModel(); //get grid's column model
  mygrid.reconfigure(ds,cm); //reconfigure the grid to show page 5
}
</script>
 
 
<script type="text/javascript">
	ColdFusion.Ajax.importTag('CFAJAXPROXY');
</script>
 
<script type="text/javascript">
	_cf_bind_init_1257493396063=function()
	{
		ColdFusion.Bind.register([['selprov','myformid','change']],{'bindTo':'province','bindToAttr':'value','cfc':'/auctioneers.cfc','cfcFunction':'getProvinces','bindExpr':[['selprov','selprov','myformid','value']]},ColdFusion.Bind.cfcBindHandler,true);
	};ColdFusion.Event.registerOnLoad(_cf_bind_init_1257493396063);
</script>
 
<script type="text/javascript">
	_cf_bind_init_1257493396064=function()
	{
		ColdFusion.Bind.register([['seldisp','myformid','change']],{'bindTo':'discipline','bindToAttr':'value','cfc':'/auctioneers.cfc','cfcFunction':'getDisciplines','bindExpr':[['seldisp','seldisp','myformid','value']]},ColdFusion.Bind.cfcBindHandler,true);
	};ColdFusion.Event.registerOnLoad(_cf_bind_init_1257493396064);
</script>
 
<script type="text/javascript">
	ColdFusion.Ajax.importTag('CFGRID');
</script>
 
<script type="text/javascript">
	ColdFusion.objectCache['Auctioneers'] = new ColdFusion.Grid.Actions('cfgrid1257493396065');
	_cf_GRIDTAG_initAjaxGrid_1257493396066=function()
	{
		var _cf_gridColModel = [{header:'Auctioneer','colName':'AUCTIONEER_1','name':'AUCTIONEER_1','dataIndex':'AUCTIONEER_1',sortType:Ext.grid.DefaultColumnModel.asUCString,sortable:true,width:225},{header:'','colName':'AUCTIONEER_SEL','name':'AUCTIONEER_SEL','dataIndex':'AUCTIONEER_SEL',sortType:Ext.grid.DefaultColumnModel.asUCString,sortable:true,width:80},{header:'Contact Details','colName':'AUCTIONEER_2','name':'AUCTIONEER_2','dataIndex':'AUCTIONEER_2',sortType:Ext.grid.DefaultColumnModel.asUCString,sortable:true,width:195},{header:'Disciplines','colName':'AUCTIONEER_3','name':'AUCTIONEER_3','dataIndex':'AUCTIONEER_3',sortType:Ext.grid.DefaultColumnModel.asUCString,sortable:true,width:172},{header:'CFGRIDROWINDEX','colName':'CFGRIDROWINDEX','name':'CFGRIDROWINDEX','dataIndex':'CFGRIDROWINDEX',sortType:Ext.grid.DefaultColumnModel.asUCString,sortable:true,hidden:true}];
		_cf_CFGRID_getData_1257493396067=function( _cf_gridDataProxy, cfgridpage, cfgridpagesize, cfgridsortcolumn, cfgridsortdirection, _cf_grid_errorhandler, _cf_callback, _cf_scope, _cf_arg,_cf_reader)
		{
			
			ColdFusion.Bind.cfcBindHandler(null, {'bindTo':ColdFusion.Grid.loadData,'bindToAttr':'true','errorHandler':_cf_grid_errorhandler,'cfc':'/auctioneers.cfc','cfcFunction':'getAuctioneers','bindExpr':[['page',cfgridpage],['pageSize',cfgridpagesize],['gridsortcolumn',cfgridsortcolumn],['gridsortdir',cfgridsortdirection],['filter','province','','value'],['filter2','discipline','','value']], 'bindToParams': { '_cf_gridDataProxy':_cf_gridDataProxy, '_cf_scope':_cf_scope, '_cf_reader':_cf_reader, '_cf_gridname':'Auctioneers', '_cf_grid_errorhandler':_cf_grid_errorhandler, '_cf_callback':_cf_callback, '_cf_arg':_cf_arg }});
		};
		var _cf_gridDataModel = new Ext.data.Store({proxy:new ColdFusion.Grid.ExtProxy(_cf_CFGRID_getData_1257493396067,null), reader:new ColdFusion.Grid.ExtReader(_cf_gridColModel), remoteSort:true, sortInfo:true});
		ColdFusion.Grid.init('Auctioneers','__CFGRID__myform__Auctioneers','myformid',true,false,true,false,_cf_gridColModel,_cf_gridDataModel,true,true,true,'#cfgrid1257493396065 .x-grid-col-0{color:#000000;} #cfgrid1257493396065 .x-grid-hd-0{color:#0B333C;font-weight:bold;} #cfgrid1257493396065 .x-grid-col-1{color:#000000;} #cfgrid1257493396065 .x-grid-hd-1{color:#0B333C;font-weight:bold;} #cfgrid1257493396065 .x-grid-col-2{color:#000000;} #cfgrid1257493396065 .x-grid-hd-2{color:#0B333C;font-weight:bold;} #cfgrid1257493396065 .x-grid-col-3{color:#000000;} #cfgrid1257493396065 .x-grid-hd-3{color:#0B333C;font-weight:bold;} #cfgrid1257493396065 .x-grid-col-4{color:#000000;} #cfgrid1257493396065 .x-grid-hd-4{color:#0B333C;} #cfgrid1257493396065 .x-grid-row-selected{background-color:#bbbbbb !important;color:white}  #cfgrid1257493396065 .x-grid-row{background-color:#bbbbbb;} ',10,false,false,null,null,{'appendKey':true,colInfo:[null,null,null,null,null]},null,null,[['province','','change'],['discipline','','change']]);
	};ColdFusion.Event.registerOnLoad(_cf_GRIDTAG_initAjaxGrid_1257493396066);
</script>
<script type="text/javascript">
<!--
    _CF_checkmyform = function(_CF_this)
    {
        //reset on submit
        _CF_error_exists = false;
        _CF_error_messages = new Array();
        _CF_error_fields = new Object();
        _CF_FirstErrorField = null;
 
 
        //display error messages and return success
        if( _CF_error_exists )
        {
            if( _CF_error_messages.length > 0 )
            {
                // show alert() message
                _CF_onErrorAlert(_CF_error_messages);
                // set focus to first form error, if the field supports js focus().
                if( _CF_this[_CF_FirstErrorField].type == "text" )
                { _CF_this[_CF_FirstErrorField].focus(); }
 
            }
            return false;
        }else {
            return true;
        }
    }
//-->
</script>
 
<script type="text/javascript">
	ColdFusion.Event.registerOnLoad(setGridToPage,null,false,true);
</script>
</head>
<body bgcolor="#ffffff">
<link href="/css/styles.css" rel="stylesheet" type="text/css">
<form name="myform" id="myformid" action="/dsp_auctioneers.cfm?selprov=All&seldisp=All" method="get" preloader="no" onsubmit="return _CF_checkmyform(this)"> <input name="selprov" id="selprov"  type="hidden" value="All" /> <input name="seldisp" id="seldisp"  type="hidden" value="All" />
 
	<table width="675" border="0" cellpadding="0" cellspacing="0">
		<tr>
			<td width="140" class="bodytextbold">Select by Province:</td>
			<td width="140" class="bodytext"><select name="province" id="province">
</select></td>
			<td width="140" class="bodytextbold">Select by Discipline:</td>
			<td width="220" class="bodytexttext"><select name="discipline" id="discipline">
</select></td>			
		</tr>
			<td></td>
		<tr>
		</tr>
	</table>
	<br />
	   
<div  id="cfgrid1257493396065" style="border: 1px solid #cccccc; overflow: hidden;">
	
 </div> <div><input type="hidden" name="__CFGRID__myform__Auctioneers" value="" /></div>
</form>
 
</body>
</html>
                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:

Select allOpen in new window

 

by: stucalPosted on 2009-11-09 at 07:09:47ID: 25776515

Further to this after playing with the code if i insert a alert between the  get datastore and the data reload like so...
ds = mygrid.getDataSource(); //get the grid's data store and
alert('test');
 ds.load({params:{start:startPage*pageSize, limit:pageSize}}); //reload data store at page 5

The function works correctly, without the alert it does not any ideas?
stu

 

by: azadisaryevPosted on 2009-11-09 at 08:00:11ID: 25777038

hmm... that's very strange...

i have just noticed that happening on first page load... but only sometimes...

my actual code is a little bit different an includes a line calling a custom grid cell renderer - maybe that's why it worked fine in my tests.

let me do a couple quick checks and post any edits back.

Azadi

 

by: azadisaryevPosted on 2009-11-09 at 08:06:32ID: 25777114

yes, removing the custom cell renderer call made it behave the way you are seeing it.

so, let's just add a fake cell rendererinto the function:

1) add this function just above setGridToPage function:
fakeRenderer = function(data,cellmd,record,row,col,store) {
  return data;
}

2) add this line
cm.setRenderer(0,fakeRenderer);
right after the cm = mygrid.getColumnModel(); line in setGridToPage function.

that should do it.

Azadi

 

by: stucalPosted on 2009-11-09 at 08:33:20ID: 25777414

hi Azadi, no still the same for me, wonder what the significance is of the alert

code as below
<script type="text/javascript">
var startPage = 3; //the page you want to reset your cfgrid to.
//IMPORTANT: the grid's page index is 0-based!
//so if you want to start at page 5 you have to set startPage to 4 above!!!
var pageSize = 10; // this should equal the value of pagesize attribute of your cfgrid!!!
fakeRenderer = function(data,cellmd,record,row,col,store) {
  return data;
}
setGridToPage = function() {
  mygrid = ColdFusion.Grid.getGridObject('Auctioneers'); // get grid object.
  //IMPORTANT: change mygrid1 above to your cfgrid's actual name (the name attribute of cfgrid)
  ds = mygrid.getDataSource(); //get the grid's data store
  ds.load({params:{start:startPage*pageSize, limit:pageSize}}); //reload data store at page 5
  //technically, we are not setting a page number - we are reloading data store to show records from page 5
  cm = mygrid.getColumnModel(); //get grid's column model
  cm.setRenderer(0,fakeRenderer);
  mygrid.reconfigure(ds,cm); //reconfigure the grid to show page 5
}
</script>

 

by: azadisaryevPosted on 2009-11-09 at 09:57:12ID: 25778286

weird...
there is no significance to the alert there i can think of apart from that it pauses processing of the code until you click 'ok' on the alert...

how much data does your query return? is it a lot of records?

it's hard for me to debug this issue because i can't consistently replicate it: the grid would not reload to specified page only sometimesand only on first page load in my tests...

let's try a couple of things, though:

1) see if changing your alert() to something non-obtrusive works as well. change it to this:
if(console!='undefined') console.log(ds);

2) try moving the ds.load(...); line to just before the last line in that function

Azadi

 

by: stucalPosted on 2009-11-12 at 22:05:43ID: 25811720

Hi Azadi

No joy with the above either i will post online the grid with and without the alert to best show what is happening.
http://www.auctioneering.co.za/dsp_auctioneerst1.cfm?selprov=All&seldisp=All with alert
http://www.auctioneering.co.za/dsp_auctioneerst2.cfm?selprov=All&seldisp=All without

I return about 140 records and the grid contains images.

aaah, in setting up this test with a completely noncashed page the the non alert test loads the firstpage, then loads the correct one then reloads the first, so the function is being run its just a timing issue

Stu

 

by: azadisaryevPosted on 2009-11-12 at 23:23:46ID: 25812032

i have figured out the problem, but not the solution (yet).

the problem is that your grid is also bound to 2 selects which are also bound to remote functions.
the call to re-render the grid to a certain page gets executed before the grid is (again) re-rendered based on the values loaded into the selects.

if you look at the requests in firebug you will see that their order is like this:
1) get grid data
2) re-render grid to selected page
3) re-render grid based on value of one of the cfselects
4) re-render grid based on value of the other cfselect
(which cfselect's binding gets excuted first depends on which cfselect gets its data first)

the 3 and 4 above get executed after the grid has been re-rendered to selected page, and the grid is rendered back to page 1.

i am trying to figure out how to make sure the call to setGridToPage() function gets executed after the grid is rendered based on inital values in the cfselects.  will post when i find a way...

Azadi

 

by: azadisaryevPosted on 2009-11-13 at 02:16:03ID: 25812706

ok, one solution is to change your cfselects to static ones instead of bound to cfc...
run 2 <cfinvoke> calls to get 2 queries for your cfselects and use these queries output to create <option>s.
you can also set bindonload="false" in your cfgrid to make fewer calls to the cfc - it will be re-rendered any way by setGridToPage function...

this one works a treat... the other solution i have come up with so far is not very elegant and not very robust because it relies on approximation of timing of cfc calls:

you can wrap the whole setGridToPage function into a setTimeout() function to make it execute after a certain time period. the problem is with guessing this time period... it has to be longer than it takes for the data to be returned for your cfselects + cfgrid to be re-rendered 2 times (once for each cfselect) + a bit of a margin.
as you can see, there's a lot of guessing involved here - it does not take the same time for data to be returned form cfc every time. in my very short tests on your sample page (reloading it about 10 times and noting execution times of cfc calls) combined time for all 4 calls was between 700ms and 2300ms. thus to be on a safe side - and this does not account for possible future data increase, either - you will have to set a timeout on setGridToPage function to about 2.5 seconds. that's quiet a waiting time AND the users will see the grid flickering (reloading) at least 3 times = very confusing for users. it is possible to hide the grid and/or pretty the page up with a spinning 'loading...' indicator until setGridToPage function executes, but a) it involves quiet a bit more code, which makes it more error-prone and harder to maintain and b) it is still at least a 2.5 seconds waiting for your users = boring boring boring.

there is likely another solution, which may be a lot better, but i have not found it yet. i have tried quiet a few other things but they either didn;t work or were even worse than the 2 solutions above.
i will need to look deep into all the events happening on the page at different times and user actions and maybe will find something.

so i suggest you go the routway of changing your cfselects to static ones - it is a far better solution. shout if you need help with this, or if you want me to post the code for the timeout solution, too.

Azadi

 

by: stucalPosted on 2009-11-13 at 02:33:46ID: 25812779

Thanks Azadi
Yes i think i will go with the static selects can i have an example of this please not used it before,
 
i am using session variables and non cashed grid pages to get around the back button to display the grid in the historic page and select state, hense this page question.

the selects sequnce the last selected option as top so the grid takes that as the starting select point

would you need to see the cfc

thanks again
stu

 

by: azadisaryevPosted on 2009-11-13 at 07:11:37ID: 25814526

try this:

1) at the top of your page put these 2 <cfinvoke> tags:
<cfinvoke component="Auctioneers" method="getProvinces" returnvariable="qProvinces">
<cfinvoke component="Auctioneers" method="getDisciplines" returnvariable="qDisciplines">

NOTES:
- make sure your getProvinces and getDisciplines functions in Auctioneers.cfc return a query (and not an array or something else).
- if the 2 cfselects do not have the correct option pre-selected, pass the url vars you populated the hidden fields with as arguments in these <cfinvoke> calls, as in cfargument-name-as-in-cfc-function="#url.selprov#"

2) change your cfselects to these:
<cfselect name="province" query="qProvinces" selected="#url.selprov#" bindonload="true"></cfselect>
<cfselect name="discipline" query="qDisciplines" selected="#url.seldisp#" bindonload="true"></cfselect>

NOTES:
- youmay have to add DISPLAY and VALUE attributes in the above 2 cfselects. set them to the names of query columns that return the value and displayed text of <option> tags in each.

3) you can remove your 2 hidden fields now

4) in your cfgrid change BINDONLOAD attribute to 'false'

that should do it.
if you see any errors - post them here.

Azadi

 

by: stucalPosted on 2009-11-16 at 23:17:33ID: 25837503

Azadi,

The selects in the cfc is setup to return as an array, is this something i can remove

cfc file added here

thanks stuart

if this is going to be impossible perhaps i can use the settimeout as an interum

 

by: stucalPosted on 2009-11-16 at 23:19:00ID: 25837507

cfc

<link href="css/styles.css" rel="stylesheet" type="text/css">
<cfcomponent output="false">
            
      <!--- Get array of provinces --->
    <cffunction name="getProvinces" access="remote" returnType="array">
            <cfargument name="selprov" type="string" required="false" default="All">
        <!--- Define variables --->
        <cfset var data="">
        <cfset var result=ArrayNew(2)>
        <cfset var i=0>

        <!--- Get data --->
        <cfquery name="data" datasource="auction">
        SELECT codevalue
            ,description
            , CASE WHEN codevalue = <cfqueryparam cfsqltype="CF_SQL_VARCHAR" value="#Arguments.selprov#" />
               THEN 0
               ELSE 1
            END AS Sort
        FROM tblregtrans
            WHERE texttypeid  = 486
        ORDER BY sort, seqno, description
        </cfquery>

        <!--- Convert results to array --->
        <cfloop index="i" from="1" to="#data.RecordCount#">
            <cfset result[i][1]=data.codevalue[i]>
            <cfset result[i][2]=data.description[i]>
        </cfloop>

        <!--- And return it --->
        <cfreturn result>
    </cffunction>
      
      <!--- Get array of disciplines --->
    <cffunction name="getDisciplines" access="remote" returnType="array">
      <cfargument name="seldisp" type="string" required="false" default="All">
        <!--- Define variables --->
        <cfset var data="">
        <cfset var result=ArrayNew(2)>
        <cfset var i=0>

        <!--- Get data --->
        <cfquery name="data" datasource="auction">
       SELECT codevalue
            ,description
            , CASE WHEN codevalue = <cfqueryparam cfsqltype="CF_SQL_VARCHAR" value="#Arguments.seldisp#" />
               THEN 0
               ELSE 1
            END AS Sort
        FROM tblregtrans
            WHERE texttypeid  = 496
        ORDER BY sort, seqno, description
        </cfquery>

        <!--- Convert results to array --->
        <cfloop index="i" from="1" to="#data.RecordCount#">
            <cfset result[i][1]=data.codevalue[i]>
            <cfset result[i][2]=data.description[i]>
        </cfloop>

        <!--- And return it --->
        <cfreturn result>
    </cffunction>
   
    <!--- Get Auctioneers --->
    <cffunction name="getAuctioneers" access="remote" returntype="struct">
        <cfargument name="page" type="numeric" required="yes">
        <cfargument name="pageSize" type="numeric" required="yes">
        <cfargument name="gridsortcolumn" type="string" required="no" default="">
        <cfargument name="gridsortdir" type="string" required="no" default="">
            <cfargument name="filter" type="string" required="false" default="ALL">
            <cfargument name="filter2" type="string" required="false" default="ALL">
            
        <!--- Local variables --->
        <cfset var Auctioneers="">
            
            <!--- Get data --->
            
            <cfquery name="dspdata" datasource="auction">
        SELECT codevalue as a1,description as a2
        FROM tblregtrans
            WHERE texttypeid  = 496
            and codevalue != 'ALL'
            </cfquery>
            
            <cfset index1=1>
            <cfset index2 = dspdata.recordcount>
            <cfset backend = "">
            <cfset thequery = "SELECT '<b>' + auctioneer_name + '</b><br>' + auctioneer_address1 + ', ' + auctioneer_address2 + '<br>' + auctioneer_town_city + '<br>' + a.description + ', ' + auctioneer_postcode + '<br><br>' as auctioneer_1, '<a href=http://www.auctioneering.co.za/auctioneer/' + auctioneer_category_id + '-#trim(arguments.filter)#-#trim(arguments.filter2)#-' +  REPLACE(REPLACE(REPLACE(auctioneer_name,' ','_'),'/','_'),',','_') + '.html target=_top class=gridselect><img src=images/s' + REPLACE(auctioneer_sub,' ','') + '.gif border=0></a><br><br>' as auctioneer_sel,'<img src=images/tel.gif> ' + auctioneer_tel + ' <br><img src=images/fax.gif> ' + auctioneer_fax + '<br><img src=images/email.gif> ' + '<a href=mailto:' + auctioneer_email + '&subject=Request_from_SAIA_Auction_Portal class=gridlinks>' + auctioneer_email + '</a>' + '<br><img src=images/www.gif> ' + '<a href=http://' + auctioneer_www + ' target=_blank class=gridlinks>' + auctioneer_www + '</a>' + ' <br><img src=images/contact.gif> ' + auctioneer_contact as auctioneer_2, auctioneer_discipline, REPLACE">
            <cfloop query="dspdata">
            <cfif index1 eq index2>
                  <cfset thequery=thequery & "(REPLACE(auctioneer_discipline, '" & "#trim(a1)#" & "','" &  "#trim(a2)#" & "')" & #backend#>
            <cfelse>
                  <cfset thequery=thequery & "(REPLACE">
                  <cfset backend=backend & ", '" & trim(a1) & "', '" & trim(a2) & "')"></cfif>
                  <cfset index1=index1+1>
            </cfloop>
            <cfset thequery=thequery & ", ',','<br>') as auctioneer_3 FROM tblregtrans a, tblAuctioneers b where auctioneer_province = a.codevalue and disabledflag = 0">
            <cfif trim(ARGUMENTS.filter) NEQ "" and trim(ARGUMENTS.filter) NEQ "ALL">
                  <cfset thequery=thequery & " and a.codevalue = '#trim(ARGUMENTS.filter)#'">
            </cfif>
            <cfif trim(ARGUMENTS.filter2) NEQ "" and trim(ARGUMENTS.filter2) NEQ "ALL">
                  <cfset thequery=thequery & " and auctioneer_discipline like '%#trim(ARGUMENTS.filter2)#%' ">
            </cfif>
        <cfif ARGUMENTS.gridsortcolumn NEQ ""
            and ARGUMENTS.gridsortdir NEQ "">
            <cfset thequery=thequery & " ORDER BY #ARGUMENTS.gridsortcolumn# #ARGUMENTS.gridsortdir#">
            <cfelse>
                  <cfset thequery=thequery & " ORDER BY auctioneer_1">
        </cfif>
            
            <cfquery name="Auctioneers" datasource="auction">#PreserveSingleQuotes(thequery)#</cfquery>
            
            <!--- And return it as a grid structure --->
        <cfreturn QueryConvertForGrid(Auctioneers,
                            ARGUMENTS.page,
                            ARGUMENTS.pageSize)>
    </cffunction>
     
</cfcomponent>

 

by: azadisaryevPosted on 2009-11-16 at 23:58:42ID: 25837683

cfselects in cf8 work just fine with queries returned as queries - you didn't have to convert the queries to arrays when you had your cfselects binded to cfc.

but now, since we are switching to <cfinvoke> calls, definitely
a) remove (or comment out) the 'Convert results to array' blocks in both getProvinces and getDisciplines functions
b) change cfreturn (in both as well) to <cfreturn data />
c) change returntype to returntype="query" in both <cffunction> tags

d) you may also have to add display="description" value="codevalue" in both of the <cfselect> tags to tell them which query column to show as options' text and which to set as options' values

Azadi

 

by: stucalPosted on 2009-11-17 at 00:54:16ID: 31650813

Azadi

Working 100's, your an absolute star thanks very much for your help, no more back button blues for cfgrid

stu

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...