Change button text for SC "automatic" buttons

Hi

In a few cases, mostly when linking to other apps, SC can (if setup on the link) add its own buttons to the linked app’s toolbar.

I am interested in 2 specific cases of this.

The first is the “Add New” button. This appears when setting “Display button (new row) on the grid toolbar” to Yes in the source Grid’s “application” link settings - see the 2 images below…

The second case is where you have a form and one of the fields is a SELECT field with lookup settings. Those lookup settings allow you (if you want to) to link to another app to change that lookup source data (add / modify etc). When run this shows itself by putting an “Edit” button next to the field’s dropdown - see images below.

Now - the question (at last!):

How can I find where to change those 2 buttons text values to something other “Add New” / “Edit”?

Now, before you all come running lots of suggestions - just read on a bit more so you can see what I’ve tried… :slight_smile:

There does not appear any configuration settings that will do this. So I first looked to see if there were language options and found things like lang_btns_neww - changing these in an event (or within the languages screen itself) didn’t (seem) to make a difference to those specific buttons.

So I looked to see if there was a clue in the generated code, or inspecting the buttons in a browser console. I couldn’t see much in the generated code, but using the browser inspector I found (for the “Add New” button):

<a href="javascript: nm_gp_submit1('/scriptcase/app/Timesheets/form_projecthours/','/scriptcase/app/Timesheets/grid_tblprojecthours/', 'projhoursid*scin9*scoutrecord_user*scinahelman*scoutrecord_tsid*scin7*scoutNM_cancel_insert_new*scin1*scoutnmgp_opcao*scinnovo*scoutNM_btn_insert*scinS*scoutNM_btn_new*scinS*scoutNM_btn_update*scinS*scoutNM_btn_delete*scinS*scoutNM_btn_navega*scinN*scoutsc_redir_insert*scinok*scout', '_blank'); return false;" id="sc_b_new_top" onclick="nm_gp_submit1('/scriptcase/app/Timesheets/form_projecthours/', '/scriptcase/app/Timesheets/grid_tblprojecthours/', 'projhoursid*scin9*scoutrecord_user*scinahelman*scoutrecord_tsid*scin7*scoutNM_cancel_insert_new*scin1*scoutnmgp_opcao*scinnovo*scoutNM_btn_insert*scinS*scoutNM_btn_new*scinS*scoutNM_btn_update*scinS*scoutNM_btn_delete*scinS*scoutNM_btn_navega*scinN*scoutsc_redir_insert*scinok*scout', '_blank'); return false;; return false;" class="scButton_default" title="Add New" style="vertical-align: middle; display:inline-block;" onmouseover="if(this.disabled){ return false; }else{ main_style = this.className; this.className = 'scButton_onmouseover'; }" onmouseout="if(this.disabled){ return false;  }else{ this.className = main_style; }" onmousedown="if(this.disabled){ return false; }else{ this.className = 'scButton_onmousedown'; }" onmouseup="if(this.disabled){ return false;   }else{ this.className = 'scButton_onmouseover'; }">Add New</a>

YUCK! Still, I wanted to see if I could use it somehow. So I used a heredoc approach (otherwise way too much escaping needed to build it as an echo string) in onApplicationInit (changing just the text at the end from Add New to Blah Blah) to see if I could replace the existing button with newly named one. Bear in mind I am not an HTML or Javascript expert by any means - but I’m always willing to try hacking to see what happens :slight_smile:

echo <<<ADZEOT
<a href="javascript: nm_gp_submit1('/scriptcase/app/Timesheets/form_projecthours/', '/scriptcase/app/Timesheets/grid_tblprojecthours/', 'projhoursid*scin9*scoutrecord_user*scinahelman*scoutrecord_tsid*scin7*scoutNM_cancel_insert_new*scin1*scoutnmgp_opcao*scinnovo*scoutNM_btn_insert*scinS*scoutNM_btn_new*scinS*scoutNM_btn_update*scinS*scoutNM_btn_delete*scinS*scoutNM_btn_navega*scinN*scoutsc_redir_insert*scinok*scout', '_blank'); return false;" id="sc_b_new_top" onclick="nm_gp_submit1('/scriptcase/app/Timesheets/form_projecthours/', '/scriptcase/app/Timesheets/grid_tblprojecthours/', 'projhoursid*scin9*scoutrecord_user*scinahelman*scoutrecord_tsid*scin7*scoutNM_cancel_insert_new*scin1*scoutnmgp_opcao*scinnovo*scoutNM_btn_insert*scinS*scoutNM_btn_new*scinS*scoutNM_btn_update*scinS*scoutNM_btn_delete*scinS*scoutNM_btn_navega*scinN*scoutsc_redir_insert*scinok*scout', '_blank'); return false;; return false;" class="scButton_default" title="Add New" style="vertical-align: middle; display:inline-block;" onmouseover="if(this.disabled){ return false; }else{ main_style = this.className; this.className = 'scButton_onmouseover'; }" onmouseout="if(this.disabled){ return false;  }else{ this.className = main_style; }" onmousedown="if(this.disabled){ return false; }else{ this.className = 'scButton_onmousedown'; }" onmouseup="if(this.disabled){ return false;   }else{ this.className = 'scButton_onmouseover'; }">Blah Blah</a>
ADZEOT;

And this is what you get - which is not what I wanted as it’s simply an extra button - but it is cool in that it puts the button AWAY from toolbar which could be useful for something else one day (??):

So - if anyone has a (hopefully simple) way to change the text on those automatic SC buttons then I’d love to hear from you. NetMake - in both those cases an extra text box in the appropriate dialog to provide your own text would be the easiest (for the user).

Thanks for reading (sorry it was a bit long).

Adz

link1.JPG

link1a.JPG

link2.JPG

link2a.JPG

link3.JPG

Really? No one has wanted to change the text of these buttons before?

Adz,

How about in the Javascript Form-> onLoad:

document.getElementById('sc_b_new_top').innerHTML = "blah blah";

Dave

Dave (sorry been away) - will try and see what happens.

Thanks

Dave

No good I’m afraid - doesn’t seem to do anything.

:frowning:

Dave

Re-read your post - just double checking… what do you mean by “in the Javascript Form”?

Did you mean - use the javascript you supplied in the onLoad event? If so, yes I tried that but not in onLoad (as it’s a grid, not a form, so no onLoad) - tried onApplicationInit and onScriptInit and onHeader - no joy :frowning:

Sorry, thought you were using a form - javascript is in the left menu on forms, you can select Form->onLoad.

ok, on a grid, in onHeader try it like this:

echo “<script>document.getElementById(‘sc_b_new_top’).innerHTML = ‘blah blah’;</script>”;

Make sure to set the ID properly.

Dave

Thanks Dave

Yeah - had already tried that - had no effect I’m afraid :frowning:

K.I.S.S!

onApplicationInit:
{lang_btns_rtrv_form} = ‘Click Here to edit’;
{lang_btns_inst} = ‘Save it here!’;
{lang_btns_neww} = ‘Add one more, for god’s sake’;

jsb

Yep, it really sucks that we have no way to insert Javascript on grids except for Javascript buttons.

jsb

There does not appear any configuration settings that will do this. So I first looked to see if there were language options and found things like lang_btns_neww - changing these in an event (or within the languages screen itself) didn’t (seem) to make a difference to those specific buttons.

I tried that - as per the quote from my original post… hence getting so frustrated - I had tried all the obvious things (I believed).

However, just to prove I wasn’t going mad I tried it again - as your post seemed so confident :stuck_out_tongue: (copying your 3 lines of code directly). Your reach is clearly omnipotent - because it only bloody worked!

Ah the frustrations of being a developer - the first thing I tried failed, but was actually the right answer. Arrrgghhh. I guess I clearly went word blind and had a typo and thus I spiralled into near insanity.

Thanks JSB, and also to you Dave, for your help!

:slight_smile: