adgreen
Posts: 27
|
| Posted: 07/20/2005, 6:10 PM |
|
(this question is targeted at CCS3.0 - but I'm assuming that the process is identical with CCS2.3)
I need to access a ListBox's underlying Recordset object, or as a second option, the complete SQL (as in with the Where and SortOrder clauses) so that I can create a matching recordset. (In this instance, if it matters, the ListBox is hosted within a Record form)
I have tried at all levels of the Event handlers available to retrieve a handle on the recordset, but without success - it is either empty, closed, or not an object. (the listbox is populating fine). Just being able to enumerate the Fields collection would suffice.
As for the SQL, it is not complete, or has "{SQL_Where} {SQL_OrderBy}" in it, which still doesn't help.
Now, I can easily get round all of this by directly editing the generated class code underneath the pages, but this defeats the purpose of using CCS in the first place, so I don't want to do it.
|
 |
 |
peterr
Posts: 5971
|
| Posted: 07/20/2005, 8:45 PM |
|
Sample code to display the SQL in the Before Show of a record form:
response.write(tasks.priority_id.DataSource.Sql & " ORDER BY " & tasks.priority_id.DataSource.Order & " WHERE " & tasks.priority_id.DataSource.Where)
You can ignore "{SQL_Where} {SQL_OrderBy}" and remove this text if you will be replacing the SQL statement.
Sample code to replace the SQL:
tasks.priority_id.DataSource.Sql = "SELECT priority_id, priority_name FROM priorities ORDER BY priority_name"
tasks.priority_id.DataSource.Order = ""
or another variant of equivalent code:
tasks.priority_id.DataSource.Sql = "SELECT priority_id, priority_name FROM priorities"
tasks.priority_id.DataSource.Order = "priority_name"
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com |
 |
 |
adgreen
Posts: 27
|
| Posted: 07/20/2005, 10:17 PM |
|
Thanks for the reply,
It turns out that my understanding of the ordering of events was wrong (and is still pretty hazy).
I wanted to directly access the recordset object of a control (which I now know is 'hidden') for both performance reasons and for an exact replica of the data. I'm generating javascript using the recordsets, and I wanted this generated javascript in the html>header section. I was using {labels} to insert my javascript code, but could not write to the label.value from an event of a control "further down" the page, and could not properly access that control from an event in the label itself as it wasn't "built" yet.
So I guess what I'm having a kind of "scoping" problem. I can't properly get controls that are hosted on the page header itself and those hosted in forms on the same page to write to each others values/methods. Note that I'm Not talking about the <form>.<control> heirarchy here. At the moment I've got a hideous system using global variables to make this all work, but am keen to understand the underlying mechanisim of the CCS Component system,
Is there a "sweet spot" in the lifetime of the page when All the controls are still readable/writeable? Or could you refer me to a discussion about the event model that CCS uses, and how and when objects are instantiated/destroyed?
I guess it would be educational to sit down and create a page a number of controls, nested in record forms etc, and trace each and every event that is 'fireable' to see the exact order, and try to glean the lifetime of page controls so that I can access them while when they contain valid data.
Thanks!
|
 |
 |
peterr
Posts: 5971
|
| Posted: 07/21/2005, 12:02 AM |
|
Sounds like you want this to be more complex than it is 
If you just scan the beginning of the generated page code you will see the simple program flow up until the "UnloadPage" section. All components are initialized, then executed one by one, then the results displayed. This is similar to procedural code with function calls where you'd output various HTML sections one by one, without relations to each other.
You cannot access one grid's controls from another grid or component, etc. - they are all independent and executed separately. The "Page" component is the main parent of all other components and in this respect you can use a page's "Before Show" event to alter component values before the page output is sent to a Web browser. This is mostly possible thanks to the template-based page processing - basically the HTML template can be still altered before it is sent to a Web browser.
Thus you can change FormName.ControlName.Value in page's Before Show event, but you cannot do much more like still trying to access a data source of a form.
The HTML templating, not object model, also allows for other "tricks" like modifying any place on a page from almost any component's event.
For example you can place the text {LabelXYZ} (like a custom label) anywhere on the page , then use the following code within any event to assign "123" value to it:
HTMLTemplate.SetVar "@LabelXYZ","123"
Also see: http://forums.codecharge.com/search.php?s_keyword=SetVa...or=&s_forum[]=6 http://forums.codecharge.com/search.php?s_keyword=tpl.&...or=&s_forum[]=6
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com |
 |
 |
adgreen
Posts: 27
|
| Posted: 07/21/2005, 1:06 AM |
|
Quote peterr:
Sounds like you want this to be more complex than it is
Sadly, it just might be true!
SetVar is exactly what I need. I've read through (ok, intensively skimmed) most of the docs, but missed this, and anything to do with the templating 'engine'.
I also didn't know that controls were isolated - but this doesn't matter now that I can wreak havac using the templating class!
Thanks for the help.
|
 |
 |
|