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!

Anchor from Grid DTC

Status
Not open for further replies.

jay219

Programmer
Nov 8, 2001
3
SA
I am in the process of creating a web application where I can provide a list of employees and have a user click over a record to show its content.

I have a grid that works fine and have used "anchor" to position a selected record. However, I would like to adopt the concept of a web mail systems such as Hotmail, Yahoo, etc. wherein a user can select among list of records and when clicked it would go to that particular record showing further details,... and hiding the grid.

I was successful modifying the column expression of grid DTC with query strings referring to another page. Through this, I can call a Request.Query() in the page being referred at to change my SELECT statement and show a certain record.But this yields one record only. How can I implement a Next and Prev navigation with this solution?

Please help. Thanks a lot.
 
The target page needs to know either how to reconstruct the underlying recordset, or you need to pass a list of index values as a parameter to the target screen. You could pass this information as part of the query-string - or using session variables.

1. reconstruct the query:
Pass the query (WHERE clause or whatever) to the target screen, together with the KEY of the selected entry. The target page can then re-SELECT the complete recordset, so you can do recordset next and prev commands. The SELECT in this page only needs to SELECT the KEY column, so it is not too inefficient. It could store this list in a hidden field, so it is only performed once - but then you would need to convert it to a comma separated list. Or you could store it as a Session variable - but you should remember to clear it at some point to free up the server memory.

2. Pass in the recordset list:
Build a comma-separated list of key values, and pass these to the target screen, together with the selected key value. Store the list in a hidden field. Convert the comma separated list to an array, to simplify the Next/Prev code.

If the list of key values is very long, then the first method is best.

How to construct & pass this information? Try the following:

Add PageObject DTCs to both pages. In the target (detail) page add a function that would recieve the selected key, and the list of prev/next keys. In the PageObject, add this function as a NAVIGATION function.
In the grid page:
In the PageObject, add a reference to the Target Page
Add a function that takes the selected key as a parameter, and in it enter:
A loop to extract the key values of the current recordset, to build the comma separated list (or the WHERE clause / selection criteria).
Then enter the name of the target (detail) screen - you should notice that the VI 'knows' about it. This is because of the PageObject reference. Complete this with the word 'navigate' then the name of the function that you added in the target page.
eg: detailPage.navigate.nav_OpenPageMethod
[assume that your function is called nav_OpenPageMethod]
VI will request the required parameters - the key list (or WHERE clause or whatever), and the selected entry:
(intSelectedKey, strKeyList)

Now you have a method on the GRID page to open the DETAIL page with enough info to do prev/next, as well as position itself on the requested entry. But how do you call this function from your grid? Try adding this function to the grid page's PageObject as a Navigate function.
Now go to the GRID and edit your expression to say:
='<A HREF=&quot;JavaScript:gridPage.navigate.nav_ShowDetails(' + [KeyColumn] + ');&quot;>Click Me!</A>'

The grid will probably not like this expression because it contains both single and double quotes. Try placing this expression into another server side function (in either JScript or VB):

gridBuildDetailLink ( intKeyValue ) {
return '<A HREF=&quot;'
+ 'JavaScript:gridPage.navigate.'
+ 'nav_ShowDetails(' + intKeyValue + ');&quot;'
+ '>Click Me!</A>';
}

The wording Click Me! could be a value passed as aother parameter.

If the KEY for the recorsdet is a string, then remember to add quotes:
+ 'nav_ShowDetails(\'' + intKeyValue + '\');&quot;'

Hope this has given you some ideas...
Good luck! (Content Management)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top