This topic is locked

Two questions about Hiding details table tab

3/26/2021 6:27:58 PM
PHPRunner General questions
Tandy author

I have been looking at this link: https://xlinesoft.com/blog/2020/05/09/hiding-details-table-tab-on-the-fly/

Question one is, Does this code go in the master table(Trip Sheets) under List page, JavaScript OnLoad event?

Question two, What parts of the code are id? I need to make them trip_id instead. Here is how I have it and does not work for me so I know I have it wrong:

$("[trip_id^=details_]").bind("click", function(){

// get ID of the current master table record
var trip_id = $(this).attr("data-record-id"), res = false;

// loop through all master table records on the page
var allRecords = pageObj.getAllRecords();
rem = false;
$.each(allRecords, function(i, row){

// If we found our record and value of OrderID is more than 10300
// than we will remove the tab. This is where you can add your own condition
if(row.recordId()== trip_id && row.getFieldText("drops")=="") //<-- Hope that means blank field
rem = true;
});
// actually removing the tab, 1 means second tab, 0 means first tab etc
if(rem) {
$("#tabs-details_details_preview"+trip_id).find("[data-tabidx=1]").remove();

// uncomment the following line if you need to hide the first tab
// $("#tabs-details_details_preview"+id").find("[data-tabidx=1]").find("a").click();
}

});

I have my field called drops and I would like to see my second tab disappear if the drops is empty.

Thanks you for any advice on this.

James