"New" ("Insert", "Add") button can't be hidden in a detail grid displayed from a master

Hi.
I’ve been struggling to be able to hide the “New” button in my grid.

I know I can:

  • remove the “Form buttons” buttons group in the Toolbar
  • use the “sc_btn_display(new, off);” macro (I tried to use it in all events).
    Nothing of this works. The “New” button keeps showing up again.

My grid is displayed from a master Form with the “master-detail” feature. Therefore there is no setting here to tell the grid to display or not the New button individually.
I tried to switch from “Grid view mode = Enable all features” to “View only”. This hides all buttons in the Toolbar, even the other buttons I want to keep. Grrrr …

I also tried to use the “sc_btn_macro” in different ways (saw them in the forum):
sc_btn_display(new, off);
sc_btn_display(“new”, “off”);
sc_btn_display(‘new’, ‘off’);
and did the same thing with “sc_btn_display(insert, off);”
This New button does not want to go away …
Any idea to help me ?
Thanks a lot.

Hi jefch, did you check this in your master form?

Regards,
Mauricio

Hi dossamau.
Yes I did and it had no effect.
But what I’ve finally done is I deleted the Edit Application Link and recreated it. Then now the “New” button disappeared …
Thanks for taking the time to respond.

Hi
I think when you create the relationship master-detail you state the visible options for new, edit and delete buttons, and these prevail over the other options (toolbar and sc_btn_display)

regards.

Hi aamartinez.
If I’m not mistaking, in the “Master-Detail” settings, there is no such thing (see printcreen #1)
What you are talking about are the settings of an application link (see printscreen #2).
In thiscase, the issue was coming I think from what dossamau pointed out (the arrow on the printscreen).

PRINTSCREEN #1

PRINTSCREEN #2

and did you try changing “Grid view mode” to “view only”?
In this case it won’t show the buttons, but I don’t know if that is what you want.

regards

Yes, I did. This hides ALL buttons, even the other buttons I want to display … so not a solution. Thx for the option.

A workaround that I implement in my code is to echo out CSS disabling the button like so:


echo "<style>#sc_b_new_t{display: none !important;}</style>";

1 Like

Thx Jeffrey. Tis is a good one. I’ll keep it.

Thanks Mauricio, that worked for me.

ooooofffffffffffffffffffff
the same problem… i do anything to hide New button in the grid but nothings work.
i try all method in my mind :
–onScriptInit—
sc_btn_display(new, off);
sc_btn_display(‘new’, off);
sc_btn_display(‘new’, ‘off’);

no one work… New button still display. this is a bug from scriptcase’s team support. and they must fix it.

image

hi.
thanks for trying help but i dont need to hide new button forever.
Sometimes i want hide & sometimes i want show new button according to condition.
i write this code :

i do this simple with condition code in event onScriptInit

if ([var_maxyear]<[actual_year]){
sc_btn_display(‘new’, ‘on’);
sc_alert(“ON”);
}else {
sc_btn_display(‘new’, ‘off’);
sc_alert(“OFF”);
}
imake sc_alert just to be sure for my condition.

When i run application it work fine without problem. But when i run project nothing happened just i see my alert message but New Button still appear.

I try to delete grid app and create new but problem still.

Maybe your Condition fails.
try convert its values to int.
if ([var_maxyear]<[actual_year])

hhh. no offcourse my condition is right.
i told you everything going well when i run application ( new button hiden and appeared automatiquelly according my condition and sc_alert too)
But when i run project my sc_alert still work but new button still appear and dont be hide.

Finnaly i solve it… now it works fine :grinning:
I just i change event.
i cut my code and paste it in event onHeader
that’s all :sweat_smile: