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!

Anyone know how to call a funtion from a grid? 1

Status
Not open for further replies.

Frank123

MIS
Sep 17, 2001
77
US
What I'm trying to do is have a unbound field on a dtc grid where if the user clicks on the field a function is called which would bring up another grid. I just don't know what to put in the grid's field/expression field to get it to call a function when clicked.. If anyone could give me some advice I'd be a happy camper..
 
You may need to add some Client-Side code - but you may ba able to use the Page Object DTC to make this easier.

There are two scenarios:
1. The grid-click does NOT cause a server round trip, and
2. The grid-click requires a server round trip

in 1 the function called must dynamically generate the HTML in the browser to render the second grid - rather browser dependent and can be code intensive.

in 2 you need to 'call' a function that only exists in the server-side. Using the Page Object DTC, this is quite easy.
* Add your server-side function to populate a second grid. Numeric parameters are easiest to use.
* Reference this function in the Page-Object 'navigate methods'.
* [optional]add a client-side script block and type thisPage.nav - by now InterDev will be beside itself trying to help you complete the code. Complete with thisPage.navigate.yourFunction(parameter1, etc.)
* You can cut this function out and add it into the grid:

='<a href=&quot;javascript:thisPage.navigate.yourFunction(' + [column1] + ', ' + [column2] + ');&quot;>' + [column3] + '</a>'

Note how your function is in quotes - it is a string. We do not want the Server-Side code to RUN your function - just to generate a hyperlink tag with the required call.

This is where numeric parameters are easiest - you do not need to quote the parameters in this grid-string.

If the quoting requirements become complex, then add a separate SERVER-SIDE function (vb or jscript) that the gridDTC calls while generating the grid:

function gridGenerateLink(aStr1, aNum, aStr2) {
//generate a hyperlink in a grid column like...
// <a href=&quot;..function('abc',3);&quot;>Hello</a>
//note the single quoting
//needed around the first (aStr1) parameter
//PS. this could be a VBSript function too
// but jscript is faster for this
// and syntax much better than VB for multiple lines
return '<a '
+ 'href=&quot;javascript:thisPage.navigate.yourFunction('
+ &quot;'&quot; + aStr1 + &quot;', &quot; + aNum + ');&quot;>'
+ aStr2 + '</a>';
}

and the GridDTC column code now looks like:
=gridGenerateLink([column1],[column2],[column3])

which is easier to type into the grid editor.
(Content Management)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top