edit pencil in a grid for each record

Hi, I have a grid with the edit pencil showing up on every row. I would like to set a flag “locked” in a table to prevent the dataset shown in one line of the grid to be edited.
With macro
sc_apl_conf(“Application”, “lig_edit”, “off”); calling from another application the pencil is hidden in every line of the grid. How can I just hide the edit pencil for that datasets where the flag “locked” is set?

I think that you will have to roll your own.

I had a need for grid row based button that would call another application with the id of the row. I got some hints on how to implement that. See this thread:

http://www.scriptcase.net/forum/foru…rm-application

One thing to remember is that you have to define an extra user defined field (i.e. not database based) for the button (btn_print) in the thread. I am not too experienced in handling the document model via JavaScript, so I am not sure if and how one would disable the button and possible change the text, but my guess is that one could make it work by playing around with it.

Hi Frank, thanks for the pointer I already found this in my searches but I think this is not exactly what I need.
The button ‘edit’ already exists (the little pencil) in each row/record. You can hide/deactivate this button with the macro I mentioned. But this has an affect to all records.
The only thing I need would be to hide this edit button depending on a flag set in the single record.

Joe

Hi Joe,

Yes, I know the edit button already exists. However, I just think that it is not possible to affect this button on a row basis via the mentioned macro. My thought was therefore that it might be better to just use JavaScript on a user defined button to make it insensitive or hide it, but I guess you may perhaps also be able to do the same with the existing edit button. However, since the existing button is handled by SC directly, it could lead to unexpected behaviour. Thus, I thought a user defined one might be better.

Unfortunately, I cannot give you specific advice here as I am only dipping a bit into JavaScript when absolutely needed and attaining the above might require some testing and playing around with it. The whole HTML, CSS and JavaScript way of programming seems really messy and spaghetti code like, coming from my background of database and desktop based object oriented programming.

Thanks Frank, but I can hardly read JS nor write some code ;-(
Does anybody know how to lock a record and prevent it from editing after a flag in the db is set?

The next best thing, if you don’t get a easy solution to disable or hide the edit button in the grid app, could perhaps be to prevent the editing in the form itself. If there is a flag on the record, you can just include it in the form as a select, put it at the top, set the value that means logged (probably a TINYINT value of 1) to display in big font “LOCKED” or such. In the on validate event section, you can check for the value of the flag field and if it is set, use sc_error_message macro to abort with a message that the record is locked and cannot be edited. Not as nice as solution, but it should be possible to get it to work without having to use JavaScript.

Good idea Frank! I will try …

OK - I deactivated all buttons in the form in dependence of my lock flag. Not nice but quick and dirty …
I’m still waiting for a better solution to hide the edit button in my grid … :wink:
Joe

Where do you put this code?

Use in onrecord

For real grid apps the pencil element ID is the same for all rows: “bedit”.
So we have to referr?ence the row id, that fortunatley is set per row noumber.

E.g., for row 3:

$( “#SC_ancor3 #bedit”).remove();

I always thought you couldn’t have a pencil to modify a row in a Grid, only on a form.

That said, I have the same problem, based on a friled in a row, in a multi-row form, I want to disable the pencil. This doesn’t seem to work for me

use inspector to get the ID of the field

I have identified the field and created in OnLoad the function

'<script>
$(
function()
{

$( “a.#sc_open_line_2.scButton_fontawesome”).remove();
}
);
</script>’;

I assume I now need to run the function. It does not have a name, how do I do this?

Hello
The solution is good for the first screen.
But not is working when you search or advance search.

Someone have a solution?