This tutorial applies to both PHPRunner and ASPRunner.NET. If we have multiple level master-details relationships expanding all details on levels programmatically can be tricky. The main issue is that details are loaded via AJAX and we don't when exactly details are loaded to ooen third level details. As a workaround we will be calling a Javascript function every two second that will check if there is more details that need to be open.In this example we will be using three level relationship Orders -> Order details -> Products.
- The code below goes to Event Editor -> custom_functions.js
function openDetails(mstimer){
setTimeout(function(){
isFound = false;
$(".details-badge").each(function(){
rowid = $(this).closest("td").attr("data-record-id");
if(!$("#gridRow"+rowid).hasClass("bs-details-opened") && rowid != "add"){
$(this).trigger("click");
isFound = true;
}
});
if(isFound)
openDetails(2000);
},mstimer);
}
This code goes through all links that open details tables, check if they are open or not and clicks the link if required. It also keeps track of many unopened links left and if there is none it exists. Otherwise it sets itself to be called again in 2 seconds.
- Now you can add the following code anywhere where Javascript can be used, i.e. to Javascript OnLoad event or to button's ClientBefore event.
openDetails(0);
0 here means that no delay is required when we call this function for the first time.