Is it possible to hide o show a column of a editable grid view ?

Is there a workaround to hide or show a column making for istance making a test over a field content … if something show else hide ?
It’s not logic .
For istance It could be nice to have a button on the header that say “Show / Hide col X”.
The problem is how to make the code that changes the display of the editable grid view adding o hiding a column
Many thanks

Hi,
how about a javascript button with this code:

var table = document.getElementById(‘hidden_bloco_0’); //table-id
var c_label = document.getElementsByClassName(‘scFormLabelOddMult’); // get the table header
var r_count = table.rows.length; // anzahl records
var c_status = c_label[3].style.display; // status of column header (3rd column in this case)
if(c_status == “none”)
{
c_status = “”;
}
else
{
c_status = “none”;
}

c_label[3].style.display = c_status; // set header hide/show

for(var i = 1; i < r_count; i++)
{
var feld = document.getElementById(‘hidden_field_data_yourfieldname_’+i); // get the field
feld.style.display = c_status; // set field hide/show
}

Hope this helps
jsb

Hi jsb,

thanks so much for your proposal. The problem is that I’m a power user and not a programmer so it seems to me a little hard to implement.
Could you please explain what these first two lines do and what I have to substitute in my form ? My Master Details DB table names are “events” & “events_rows”.
The column I have to hide/show is within ‘events_rows’ form called ‘form_events_rows’ and the column name is ‘external_subscriber’ and it’s the 3rd field on details form.

var table = document.getElementById(‘hidden_bloco_0’); //table-id
var c_label = document.getElementsByClassName("scFormLabelOddMul t); // get the table header

and this
var feld = document.getElementById(‘hidden_field_data_pen_tex t_’+i); // get the field

Many thanks

Hi giovannino,
what this piece of code does is iterate through your table and switch on/off the required field.
So keep in mind it may be a bit slow on big tables.

The first line is to identify the table in which to hide/show the column and SC uses ‘hidden_bloco_0’, but you can double check by viewing the page source in your browser.
The second line is to identify the header line of your table (you have to Hide/show it separately). Again SC uses ‘scFormLabelOddMult’ for it.
So for those two lines you don’t have to substitute anything.

In
var feld = document.getElementById(‘hidden_field_data_pan_text_’+i) you identify the exact field/column in your table to show/hide. The variable i defines the actual row while you are iterating through the table.

In your case the line should read

var feld = document.getElementById(‘hidden_field_data_external_subscriber’+i);

Oh, and for the column count, don’t forget to count the field with the edit/delete icon. :slight_smile:
So in your case it’s probably c_label[4].style.display

Take care
jsb

// Inspect and find the Row
// OnAplicationInit
// First for the head hidden_field_data_sc_seq
// Second for the Rows sc-id-fixed-headers-row-0
echo '<script> $( function() { $("[id^=hidden_field_data_sc_seq]").hide(); $("tr[id=sc-id-fixed-headers-row-0").find("td:first").attr("colspan",1); } ); </script>';

////// Other Option
echo '<script> $( function() { $("[id^=hidden_field_label_obs3_]").hide(); $("[id^=hidden_field_data_obs3_]").css("display", "none");; } ); </script>';