Adding record in nested grid

As in the header, I have a Parent/Child App, with nested grid. How can I add a Add/Change/Delete buttons on the nested grid ? When creating a link I have had all aptions checked to add appropriate buttons but when running and App no buttons are present.

Arthur

Re: Adding record in nested grid

The easiest would be to create a “New Field” for the nested grid and define it as “HTML Image”.
In the process you can select an image for it and configure all the parameters you need.

Re: Adding record in nested grid

Sadarahu:

Have you solve the problem ?
The jsbinca’s solution adds an “add button” on each row of the nested grid, but It doesn?t work when the grid is empty (and no rows show) and when It doesn’t is empty to have several “add” buttons (one for each row) doesn’t seem has sense.

I think that the button must be on the toolbar (top of the nested grid).
Any idea or solution?

Thanks.
Pablo.

Hi,
as a newbie it’s very hard to find the suitable information. There are hundreds of hits with ‘grid’ or ‘link’ … So please be patient with us beginners :wink: I didn’t find the solution to the ‘adding record in nested grid’ problem.

How could that be done?

Joe

A nested grid is what it says: a grid. You cannot add records in a grid, you need a form to do that. But you could try to add a link to the nested grid that goes to a modal form for instance.

Hello Albert, thanks for your answer.

I don’t want to add records into a grid. I just want a button/link in the nested grid (header) to call a form to add a record.
I could do this by adding a link to the record in the grid but this is useless if there is no record and I want to add the first one.

If I run the nested grid as ‘standalone’ it shows a header (and footer) where I have an add button which leads me to my form. But as nested grid the header and footer is not displayed.
I hope you understand what I mean.

Joe

[QUOTE=Joe;32897]Hello Albert, thanks for your answer.

I don’t want to add records into a grid. I just want a button/link in the nested grid (header) to call a form to add a record.
I could do this by adding a link to the record in the grid but this is useless if there is no record and I want to add the first one.

If I run the nested grid as ‘standalone’ it shows a header (and footer) where I have an add button which leads me to my form. But as nested grid the header and footer is not displayed.
I hope you understand what I mean.

Joe[/QUOTE]

I understand what you mean, but because a nested grid doesn’t show the header/footer you cannot add buttons to it. But what might be possible is that you add a custom field of type image. Then you can apply a link to a form. Perhaps that solves your issue.

I think this only works if you already have at least one record. But if you want to create the first record there will be no image link.

Would it be possible to add a button/link to the master grid header and call a form? In this case I would need to transfer a variable to the button that the child record will be written to the correct master record. How would this be done?

Just a thought - in grids you can select a row by clicking it once with your mouse and it changes colour. By doing this, is there a value generated which I can use as a variable for my link/button?

Joe

I don’t know actually, but it’s worth trying. Sometimes you have to be creative and find work-arounds to get things done. Not always the nicest possible method, but you have to do with what you get.

I think another method to that would be to:

  1. Select a parent record (i.e checkmark)
  2. do the background lookup (SC_lookup…) macro to find child record (in case of adding new record this is not needed)
  3. call FORM App

In my desktop tool each call from the browse to the form trigers a STATUS variable which can be: 1-Add 2-Chenge 3-Delete 4-Lookup 5-View
Based on its value the form can take different actions and can present/hide fields etc. It is smart and convenient way of working with grids. I also do not understand why SC does not provide DELETE button by default (although I know it can be programmed). Basically all 5 actions should be available from the grid and having to open a FORM in order to delete record is very inconvenient.

Arthur

Thanks Arthur, I’ll give it a try with my limited knowledge.

Joe

I got in this topic as i wanted to add new records via the nested grid. Actually it does not matter if the grid has records or not , as said, the header is blocked.
the trick is to use OnInit event inside your nested grid. So go the the grid that is nested and find under Events the OnInit event. This will open PHP code editor.

In the event you apply the same trick as in https://asdw.de/en/place-button-at-any-place-of-scriptcase-form-grid/. except one difference. You have to Echo the link code.
It works pretty awesome and you get a small button in the nested grid that brings you to the actual form. BTW [SIZE=12px]sc_make_link macro is awesome![/SIZE]

Few remarks: you might play with target attribute of the link as default it will open the form in the same window
if your edit form is using parameters in sql where, be carefull to put ’ ’ quotes around your global parameter. Otherwise when your nested grid has no records and you open the form it will pass Null as the value. this will give sql error if you your parameter not enclosed (something like where id=’[parameter]’ . Actually i recommend always enclose parameters in any sql where.