PDA

View Full Version : Using a Button to redirect to different Page



Steven Lemarr
8-Jan-2007, 04:25 PM
Using Alpha 2.

I have a grid with a button on each line and I would like to the redirect
the user to a different ASP page with the rowid when the button is press.
The new page should display a new grid using a child file of the record
selected from the previous page. I have tried several varations of
Javascript sample from several books and I just cannot get it to work. If I
could get a sample of how this is done it would sure be helpful.

Steve

Harm Wibier
12-Jan-2007, 07:37 AM
Hello Steven,

The first problem to be solved is to fetch the rowid of the selected row in
the grid. This rowid can be fetched from the VdfForm object that can be
found using getVdfControl("formname") or findForm(this) when inside the
form. The following line demonstrates how to fetch the rowid:

sRowid =
getVdfControl("orderhead_form").getStatusField("orderdtl__rowid").getValue();


Redirecting to other pages from javascript is usually done by setting
document.location.href property so the complete redirection to a page with
the rowid will make:

document.location.href = "childformpage.asp?rowid=" +
getVdfControl("orderhead_form").getStatusField("orderdtl__rowid").getValue();


Now this code needs to be executed when the button is clicked. The code can
be placed directly in the onclick property but when more buttons have the
same action i advice to make a function in the header. The following line
demonstrates how the code can be place in the onclick property:

<input type="button" onclick="document.location.href =
childformpage.asp?rowid=' +
getVdfControl('orderhead_form').getStatusField('or derdtl__rowid').getValue();">


You mentioned that there was a button on every line, so also on the display
line of the grid. When the button on the display line is clicked you first
want to select this line so the correct rowid is given to the child page. To
do this the selectByRow(oHtmlRow) method of the VdfGrid should be called.
This method returns true if the line is selected (because if the a save can
fail) so this makes the following code:

if(getVdfControl('orderdetail_grid').selectByRow(t his)){
document.location.href = "childformpage.asp?rowid=" +
getVdfControl("orderhead_form").getStatusField("orderdtl__rowid").getValue();
}


Because this is a bit long to do in a onclick property i would create the
followin function in the header:

<script type="text/javascript">
function openChildPage(){
var sRowid;

sRowid =
getVdfControl("orderhead_form").getStatusField("orderdtl__rowid").getValue();
document.location.href = "childformpage.asp?rowid=" + sRowid;
}
</script>

And inside the displayrow:
<input type="button"
onclick="if(getVdfControl('orderdetail_grid').selectByRow(t his)){
openChildPage(); }">

And inside the editrow:
<input type="button" onclick="openChildPage();">


I hope this answers the question!

Regards,


--
Harm Wibier
Data Access Europe B.V.
http://www.dataaccess.nl

"Steven Lemarr" <steve@jahl.com> wrote in message
news:dBQG0y2MHHA.1464@dacmail.dataaccess.com...
> Using Alpha 2.
>
> I have a grid with a button on each line and I would like to the redirect
> the user to a different ASP page with the rowid when the button is press.
> The new page should display a new grid using a child file of the record
> selected from the previous page. I have tried several varations of
> Javascript sample from several books and I just cannot get it to work. If
> I could get a sample of how this is done it would sure be helpful.
>
> Steve
>

Steven Lemarr
12-Jan-2007, 06:38 PM
Thank have the redirection to the next page is working with the RowId being
passed. Now when I get to the next page I am have trouble finding the
record by RowId and getting anything to display.

The more I read about Javascript & ajax the more confused I get, but with
your help I am slowly starting to understand some of this.

Steve

"Harm Wibier" <harm.wibier@dataaccess.nl> wrote in message
news:OyrW8ZkNHHA.3744@dacmail.dataaccess.com...
> Hello Steven,
>
> The first problem to be solved is to fetch the rowid of the selected row
> in the grid. This rowid can be fetched from the VdfForm object that can be
> found using getVdfControl("formname") or findForm(this) when inside the
> form. The following line demonstrates how to fetch the rowid:
>
> sRowid =
> getVdfControl("orderhead_form").getStatusField("orderdtl__rowid").getValue();
>
>
> Redirecting to other pages from javascript is usually done by setting
> document.location.href property so the complete redirection to a page with
> the rowid will make:
>
> document.location.href = "childformpage.asp?rowid=" +
> getVdfControl("orderhead_form").getStatusField("orderdtl__rowid").getValue();
>
>
> Now this code needs to be executed when the button is clicked. The code
> can be placed directly in the onclick property but when more buttons have
> the same action i advice to make a function in the header. The following
> line demonstrates how the code can be place in the onclick property:
>
> <input type="button" onclick="document.location.href =
> childformpage.asp?rowid=' +
> getVdfControl('orderhead_form').getStatusField('or derdtl__rowid').getValue();">
>
>
> You mentioned that there was a button on every line, so also on the
> display line of the grid. When the button on the display line is clicked
> you first want to select this line so the correct rowid is given to the
> child page. To do this the selectByRow(oHtmlRow) method of the VdfGrid
> should be called. This method returns true if the line is selected
> (because if the a save can fail) so this makes the following code:
>
> if(getVdfControl('orderdetail_grid').selectByRow(t his)){
> document.location.href = "childformpage.asp?rowid=" +
> getVdfControl("orderhead_form").getStatusField("orderdtl__rowid").getValue();
> }
>
>
> Because this is a bit long to do in a onclick property i would create the
> followin function in the header:
>
> <script type="text/javascript">
> function openChildPage(){
> var sRowid;
>
> sRowid =
> getVdfControl("orderhead_form").getStatusField("orderdtl__rowid").getValue();
> document.location.href = "childformpage.asp?rowid=" + sRowid;
> }
> </script>
>
> And inside the displayrow:
> <input type="button"
> onclick="if(getVdfControl('orderdetail_grid').selectByRow(t his)){
> openChildPage(); }">
>
> And inside the editrow:
> <input type="button" onclick="openChildPage();">
>
>
> I hope this answers the question!
>
> Regards,
>
>
> --
> Harm Wibier
> Data Access Europe B.V.
> http://www.dataaccess.nl
>
> "Steven Lemarr" <steve@jahl.com> wrote in message
> news:dBQG0y2MHHA.1464@dacmail.dataaccess.com...
>> Using Alpha 2.
>>
>> I have a grid with a button on each line and I would like to the redirect
>> the user to a different ASP page with the rowid when the button is press.
>> The new page should display a new grid using a child file of the record
>> selected from the previous page. I have tried several varations of
>> Javascript sample from several books and I just cannot get it to work.
>> If I could get a sample of how this is done it would sure be helpful.
>>
>> Steve
>>
>
>

Harm Wibier
12-Jan-2007, 07:29 PM
The VdfForm has an autoload feature which means that it checks the rowid
fields on initialization. If any rowid's are found it does a findByRowId and
loads the data. The rowid can be fetched from the request parameters using
ASP with its Request collection. The following line demonstrates how this
value can be fetched and printed in the html input elements value property:
<input type="hidden" size="15" name="invt__rowid" value="<%=
Request("rowid") %>" />

The autoload feature is enabled by default but to make sure it is enabled
the bAutoFill setting of the VdfForm can be set using the following line:
<form action="none" name="form1" autocomplete="off" vdfControlType="form"
vdfControlName="inventory_form" vdfMainTable="invt" vdfWebObject="oInvt"
vdfAutoFill="true">


An alternative way of loading the data is by doing a find from asp on the
webobject, but this only works when the input fields are generated using
DDValue and does not works on VdfLookups and VdfGrids!

I am happy that my explanations clarify a bit because the combination of
asp, vdf, html and javascript / ajax brings a big learning curve!

Regards,


--
Harm Wibier
Data Access Europe B.V.
http://www.dataaccess.nl


"Steven Lemarr" <steve@jahl.com> wrote in message
news:AjBuHQqNHHA.3744@dacmail.dataaccess.com...
> Thank have the redirection to the next page is working with the RowId
> being passed. Now when I get to the next page I am have trouble finding
> the record by RowId and getting anything to display.
>
> The more I read about Javascript & ajax the more confused I get, but with
> your help I am slowly starting to understand some of this.
>
> Steve
>
> "Harm Wibier" <harm.wibier@dataaccess.nl> wrote in message
> news:OyrW8ZkNHHA.3744@dacmail.dataaccess.com...
>> Hello Steven,
>>
>> The first problem to be solved is to fetch the rowid of the selected row
>> in the grid. This rowid can be fetched from the VdfForm object that can
>> be found using getVdfControl("formname") or findForm(this) when inside
>> the form. The following line demonstrates how to fetch the rowid:
>>
>> sRowid =
>> getVdfControl("orderhead_form").getStatusField("orderdtl__rowid").getValue();
>>
>>
>> Redirecting to other pages from javascript is usually done by setting
>> document.location.href property so the complete redirection to a page
>> with the rowid will make:
>>
>> document.location.href = "childformpage.asp?rowid=" +
>> getVdfControl("orderhead_form").getStatusField("orderdtl__rowid").getValue();
>>
>>
>> Now this code needs to be executed when the button is clicked. The code
>> can be placed directly in the onclick property but when more buttons have
>> the same action i advice to make a function in the header. The following
>> line demonstrates how the code can be place in the onclick property:
>>
>> <input type="button" onclick="document.location.href =
>> childformpage.asp?rowid=' +
>> getVdfControl('orderhead_form').getStatusField('or derdtl__rowid').getValue();">
>>
>>
>> You mentioned that there was a button on every line, so also on the
>> display line of the grid. When the button on the display line is clicked
>> you first want to select this line so the correct rowid is given to the
>> child page. To do this the selectByRow(oHtmlRow) method of the VdfGrid
>> should be called. This method returns true if the line is selected
>> (because if the a save can fail) so this makes the following code:
>>
>> if(getVdfControl('orderdetail_grid').selectByRow(t his)){
>> document.location.href = "childformpage.asp?rowid=" +
>> getVdfControl("orderhead_form").getStatusField("orderdtl__rowid").getValue();
>> }
>>
>>
>> Because this is a bit long to do in a onclick property i would create the
>> followin function in the header:
>>
>> <script type="text/javascript">
>> function openChildPage(){
>> var sRowid;
>>
>> sRowid =
>> getVdfControl("orderhead_form").getStatusField("orderdtl__rowid").getValue();
>> document.location.href = "childformpage.asp?rowid=" + sRowid;
>> }
>> </script>
>>
>> And inside the displayrow:
>> <input type="button"
>> onclick="if(getVdfControl('orderdetail_grid').selectByRow(t his)){
>> openChildPage(); }">
>>
>> And inside the editrow:
>> <input type="button" onclick="openChildPage();">
>>
>>
>> I hope this answers the question!
>>
>> Regards,
>>
>>
>> --
>> Harm Wibier
>> Data Access Europe B.V.
>> http://www.dataaccess.nl
>>
>> "Steven Lemarr" <steve@jahl.com> wrote in message
>> news:dBQG0y2MHHA.1464@dacmail.dataaccess.com...
>>> Using Alpha 2.
>>>
>>> I have a grid with a button on each line and I would like to the
>>> redirect the user to a different ASP page with the rowid when the button
>>> is press. The new page should display a new grid using a child file of
>>> the record selected from the previous page. I have tried several
>>> varations of Javascript sample from several books and I just cannot get
>>> it to work. If I could get a sample of how this is done it would sure be
>>> helpful.
>>>
>>> Steve
>>>
>>
>>
>
>