Forums
Script for the Freeze Header - Printable Version

+- Forums (https://bdn.bdb.ai)
+-- Forum: BDB Knowledge Base (https://bdn.bdb.ai/forumdisplay.php?fid=13)
+--- Forum: BDB Dashboards Designer (https://bdn.bdb.ai/forumdisplay.php?fid=43)
+---- Forum: BDB Designer Q & A (https://bdn.bdb.ai/forumdisplay.php?fid=16)
+---- Thread: Script for the Freeze Header (/showthread.php?tid=363)



Script for the Freeze Header - rubeena.hajira - 12-22-2022

Script for the Freeze Header?

*Below Script to be written on the Dashboard script as it is:

sdk.freezeHeader = function (grpName) {    var headerArr = $(".g_" + grpName); 
   //  group-name which needs to be fixed   
   var headerArrCompOffset = {};    
   var dashOffset = $(".draggablesParentDiv").offset(); 
   var maxZIndex = sdk.dashboard.m_widgetsArray.length;
   for (var i = 0; i < headerArr.length; i++) {        var compOffset = $(headerArr[i]).position();    
   /** make the hidden elements visible, get the position and hide again **/     
if ($(headerArr[i])[0] && $(headerArr[i])[0].style.display == "none") {            $(headerArr[i])[0].style.display = "block";  
   compOffset = $(headerArr[i]).position();            $(headerArr[i])[0].style.display = "none";        }     
var leftPos = compOffset.left * 1 + dashOffset.left * 1;   
headerArrCompOffset[headerArr[i].id] = compOffset.left * 1;       
sdk.applyStyles(headerArr[i], {            "position": "fixed",            "left": leftPos + "px",            "z-index": maxZIndex        });    }
$(document).scroll( function(scroll){        var dashOffset = $(".draggablesParentDiv").offset();   
for (var i = 0; i < headerArr.length; i++) {                var leftPos = headerArrCompOffset[headerArr[i].id] + dashOffset.left * 1 - $(window).scrollLeft();  
$(headerArr[i]).css('left',  leftPos);        };    });        
   $( window ).resize(function() {        var dashOffset = $(".draggablesParentDiv").offset();    
for (var i = 0; i < headerArr.length; i++) {                var leftPos = headerArrCompOffset[headerArr[i].id] + dashOffset.left * 1 - $(window).scrollLeft();            
$(headerArr[i]).css('left',  leftPos);        };    });    
};

*This Script should be written in the script of the First loading connection in the Dashboard.
*Should create a group of components that should be frozen and then that group name should be added in a script as written below(group name:fc):

sdk.freezeHeader('fc');