Web Connection
Calling Foxpro function from HTMLDataGrid
Gravatar is a globally recognized avatar based on your email address. Calling Foxpro function from HTMLDataGrid
  Kathy
  All
  Feb 21, 2019 @ 10:04am

Hello,
Please forgive my basic questions but can we run a Foxpro function by clicking on a field on HTMLDataGrid without launching to any page?
I know we can call functions while we're creating the grid, like: loColumn = loConfig.AddColumn([Process.LinkAlbum()],"Album") but I need to do something behind the scene by clicking on the fields.
Thanks,
Kathy

Gravatar is a globally recognized avatar based on your email address. re: Calling Foxpro function from HTMLDataGrid
  Rick Strahl
  Kathy
  Feb 21, 2019 @ 11:15am

I know you're coming from Web Control framework so you expect something like a button click that fires an event on the server, right?

This sort of thing you typically handled with a link (I think that's what you're referring to with Process.LinkAlbum()) that just fires another request with an id. What's different there is that the state of change isn't automatically reflected back into the original page. You can however, link or post back to the same page that hosts the link, so when you process your server code you can re-render the grid when you are done. In the process method you can have a CASE statement:

FUNCTION InvoiceDisplay

DO CASE
  CASE action="recalculateitems"
      this.RecalculateLineItem()
  CASE action="deleteitem"
      loBusItem.Delete(lcId)
  ...
ENDIF

*** Page State Configuration
loBusInvoice.Load(lcInvId)

Response.ExpandScript()

You can either do that processing inline, or offload to other methods, or if necessary even entire external classes or business objects.

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: Calling Foxpro function from HTMLDataGrid
  Kathy
  Rick Strahl
  Feb 22, 2019 @ 07:45am

Thank you so much Rick.
Just need a quick confirmation.
I need to run a function prior to launching another page and since I don't need the reflection on the current page and I'd like to hide the query string and parameters as much as possible, I was thinking I might be able to call process methods the way we can do during creating the data grid like: loColumn = loConfig.AddColumn([Process.LinkAlbum()],"Album") but now I assume it still has to be done by query string. Is that right?
So I assume I have to use HREF() or HTMLlink() to call the same page and send the "action" which could be the id of what's been clicked and then handle the page considering what's been sent through query string.
And I assume I cannot use something like loColumn = loConfig.AddColumn(HREF([same_page.wwd],[Run_myCode],[ onclick='<%= myCode() %>';' ]))
Would you please correct me if I'm wrong?
Thanks again.

Gravatar is a globally recognized avatar based on your email address. re: Calling Foxpro function from HTMLDataGrid
  Rick Strahl
  Kathy
  Feb 22, 2019 @ 01:52pm

Correct. You can't just call another method, you have to link to something else. The Web Control framework made it seem like you could just 'call a method' from the button, but really it was POSTing back to the same request that you were currently running.

You can still do that and in fact that might be the way to do this. You basically call the same URL you are on (say your're on invoice.wcs then call back with invoice.wcs?action=add or invoice.wcs?action=delete etc.). This way you can kind of do the same thing that the Web Control framework did although you have to pass state back to the request (ie. Ids and anything saved on the form).

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: Calling Foxpro function from HTMLDataGrid
  Kathy
  Rick Strahl
  Feb 25, 2019 @ 08:43am

I got it now.
Thank you so much,
Kathy

© 1996-2024