Web Connection
Help with HtmlButton
Gravatar is a globally recognized avatar based on your email address. Help with HtmlButton
  Chris Jewell
  All
  Mar 18, 2019 @ 06:29am

Hi, I'm new to WC so apologies if this is a simplistic question.

This hyperlink column works as expected:

loConfig.AddColumn([HtmlLink("UpdatePrintDate.wc?job=" + TRANSFORM(CurUserAlloc.job),"Print Done")],"Action")

But, I’d like to use the ‘HtmlButton’ class, I’ve tried and tried but I cannot get it to work :

cOnClick2 = [onclick="location.href='UpdatePrintDate.wc?job=' + TRANSFORM(CurUserAlloc.job)"]

cURLLink2 = "class='btn btn-default' "+ cOnClick2

loConfig.AddColumn("HtmlButton([Print3]+TRANSFORM(CurUserAlloc.Job),[Print Done],cURLLink2)","Action")

The issue is nothing happens when I click the button, but if I hardcode in a job number then the statement works:

cOnClick3 = [onclick="location.href='UpdatePrintDate.wc?job=12345'"]

cURLLink3 = "class='btn btn-default' "+ cOnClick3

loConfig.AddColumn("HtmlButton([Print4]+TRANSFORM(CurUserAlloc.Job),[Fixed Job],cURLLink3)","Fixed Job")

Any advice would be appreciated.

Thanks, Chris

Gravatar is a globally recognized avatar based on your email address. re: Help with HtmlButton
  Mike McDonald
  Chris Jewell
  Mar 18, 2019 @ 10:29am

Chris -

I think that doesn't work because HTMLButton() doesn't evaluate the lcAttributes parameter (which contains your TRANSFORM() call). HTMLLink() does evaluate the lcLink parameter.

A better option might be to stick with HTMLLink(), but simply style the link to appear like a button. If you are using the Bootstrap framework, this can be done by passing [class="btn btn-primary"] for the third (lcAttributes) parameter to HTMLLink(). Otherwise you'll need to apply some special CSS for your link.

- Mike McDonald

Gravatar is a globally recognized avatar based on your email address. re: Help with HtmlButton
  Rick Strahl
  Chris Jewell
  Mar 18, 2019 @ 08:26pm

Can you please edit your post and highlight your code so it's readable...

As Mike pointed out, you can't put an expression into the attributes parameter because that value is not evaluated - it's taken as a literal. But you can assign the value directly by creating the attribute string as a static value:

HtmlButton("btnSumbit","Hit me!",[onclick="location.href='UpdatePrintDate.wc?job=] + TRANS(CurUserAlloc.job) + ['"])

Note the difference that the value is hardcoded into the expression, rather than 'evaluating' inside of the expression which never happens on the attribute.

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: Help with HtmlButton
  Chris Jewell
  Chris Jewell
  Mar 19, 2019 @ 03:20am

Thank you both for your quick replies, Ricks solution worked perfectly 😃

© 1996-2024