Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Specify Grid row/page 1

Status
Not open for further replies.

slr22

MIS
Jun 26, 2002
80
US
I have a grid in visual interdev that is displayed when someone queries specific information. When they query this information sometimes there are multiple pages. When the person gets to the grid, they can click on a specific row within the grid and then press another button to get detailed information. My question is when the person goes back to the grid after seeing the detailed information, is there a way to specify what grid row/page they were previously on and bring them back to that row/page. Currently it brings them back to the first row of the first page and if there is a lot of pages, then the person has to keep pressing the page button to get back to the page that they were on.

Thanks in advance.

Sandy
 
Store the recordset bookmark (or any other key) somewhere - say in a Session value or passed on to the details page as a parameter.

If you use the Page Object DTC, then creating a Session value is even easier - just add a property to the Page Object DTC, with session scope. Then you can read and write the value very easily:

store the bookmark:
thisPage.setMyValue rsMyRecordset.bookmark

retrieve the bookmark:
rsMyRecordset.bookmark = thisPage.getMyValue()

Using the session / Page Object will mean that the page will always go to that grid page (it always finds the correct page for the current row) for the rest of that users session - no matter how they navigate to the grid page.

By passing the bookmark as a query parameter to the details page and back again, then the grid only repositions to a given page after returning from the details page.


OR you could pop-up the details page in a separate browser window (you would need to add some client-side javascript or hyperlink with a named 'target' attribute). With care, this can be the best solution. (Content Management)
 
Is there a way to open a window using a button instead of a link? I know how to do it using a link, but I'm unfamiliar on how to do it using a button. Normally when I want to open a page I use vbscript saying

Sub btnrpt_onclick()
Response.Redirect ("Reports.asp")
End Sub

I tried doing window.open, but it gives me an error:

Microsoft VBScript runtime error '800a01a8'

Object required: 'window'

I really would like to be able to open and close the windows using buttons instead of a link. Any help would be appreciated.
 
Here are two ideas:

- Make a gif image that looks like a button, and plonk that in the hyperlink <a...> tag.

- Add an HTML button (submit or button) and include an onclick attribute. You must enter some JavaScript in the onclick value. You could use the 'window.open(...)' command to open a new browser window (which can take loads of parameters). Or you could load another page into the current browser using 'document.location.href = ...'
(this is from memory, so you had better get your documentation out on these).
(Content Management)
 
Thanks MerlinB

I was using the window.open(&quot;page.asp&quot;) however I was using it in VBscript instead of javascript and that is why it was giving me an error. I have it working now. Thanks so much for the help.
 
I've built a calendar application in MS Access and I am using VI6.0 to display it in .asp pages on our intranet.

By default, the grid displays page 1 of the data, which in this case will always show events which are six months old. I want it to display current events by default instead, i.e. display whichever page contains events closest to today's date, although still allowing users to see previous months' data by paging back.

If you can help, please be very specific as this is my first time using VI. Be gentle with me.

By the way - to generate the grid I am using a template wizard called RuleZero which automatically provides the sort and filter functionality.

Regards to all
 

Hi All

Further to my previous post, I've created a recordset which is limited to records whose date is less than today's. Doing getCount() on this recordset gives me the number of records I need to page through in the full recordset to reach today's (or the nearest to today's). I've also written a script which does the paging to the correct record.

I have buttons to allow the user to page through, sort and filter the data, and they can change the data view from a list to a detail view. Each of these actions appears to trigger the
Code:
thisPage_onenter
event, where I initially placed my script, so that today's record gets highlighted again even when the user is specifically paging away from it or selecting another record.

Question: if not
Code:
thisPage_onenter
, where do I put the script so that it runs only when the page is first loaded?

Help would be greatly appreciated!

Sorry for my prolixity (I love that word!)

Mac
 
just add this to your _onenter code:

if thisPage.firstEntered then
'code here for first page load only
else
'code hare for subsequent round-trips
'can be handy for auto-save update forms
end if

 
Thanks, MerlinB

I added the
Code:
.firstEntered
property as instructed. My calendar now opens at the appropriate record. Brilliant!

However (there had to be a 'however'), when the user filters the data using the functionality provided by the RuleZero template mentioned above, an error sometimes occurs.

Code:
ADODB.Recordset (0x800A0BB9)
Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.

I am guessing that
Code:
.firstEntered
is true again when the filter is applied and the data page is redisplayed, and so if the filter does not return enough records, this error occurs. When a large number of records are returned by the filter, it works perfectly.

So - I think I am looking for another
Code:
.firstEntered
kind of thing, but at a level up. Some event that fires the first time the page is loaded, and then never again. Is there such an event?

Thanks again.

Mac
 
I don't know RuleZero, but anyway these tips may help:

- To see what (SOM) events are executed and in what order, try turning on the event trace. At the top of your asp page there should be a line with @trace = false. Just change it to true and save the file. Now refresh the browser page, and loads of extra text gets pumped out. If this trace facility is not in your ASP, then you have not SOM (Script Object Model) enabled your page - just add a Page DTC (Design-Time control).

- If you try to set an SQL parameter of a DATE type, it may well go wrong after the first page round-trip. This is because the selected date is held as a string in a hidden form value on the web page. When you request a server round-trip, it tries to re-open the SQL with the parameter - which must be converted from string to date. Sometimes this conversion fails - and you get error like the one you reported.



 
Thanks, MerlinB

My page (as generated by RuleZero) claims
Code:
VI 6.0 Scripting Object Model Enabled
. There is no @trace command. Can I write it in manually somewhere?

Just to reiterate, to get to today's date in the full recordset I am simply doing a count of all those records whose event date is less than today's date. Then I am paging through the appropriate number of records. Not too sophisticated.

When the records are filtered,
Code:
.firstEntered
is (I think) firing again, and again trying to page through the same number of records. If the filter returns fewer than that number, I get the error.

The other solution I was thinking about was to loop through each record until the event date is equal to or greater than today. This should work with
Code:
.firstEntered
regardless of the number of records returned. I've been struggling with the appropriate syntax for this, however.

Thanks for your interest!

Mac
 
Try this: Top of the page could look a bit like this:

<SCRIPT id=DebugDirectives runat=server language=javascript>
// Set these to true to enable debugging or tracing
@set @debug=false
@set @trace=false
</SCRIPT>

<% ' VI 6.0 Scripting Object Model Enabled %>
<!--#include file=&quot;_ScriptLibrary/pm.asp&quot;-->
<% if StartPageProcessing() Then Response.End() %>
<FORM name=thisForm METHOD=post>


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top