great little <NetSuiteHub.com post> that I want to...
# general
d
great little NetSuiteHub.com post that I want to share: "Locked Sublist Column Headers" ITT: short excerpt/discussion and the code to do so (with Tampermonkey browser extension/add-on)
Here's the Tampermonkey script I use, adapted from @michoel’s script in the thread. I added a mutation observer that will re-run the script each time the machine table container changed (IIRC this was happening every time you sorted the table). I also changed the height to 60% (
60vh
) and added the
overflow-y: scroll
now, I think you could do the classic script injection using a client script into a hidden html field, but I haven't tried this and instead just use Tampermonkey to add the script in to any
*.<http://netsuite.com/*|netsuite.com/*>
pages
m
@netsuite_insights published an article with an adaption of this in a client script. https://netsuite.smash-ict.com/netsuite-sticky-headers/ The advantage of that is it gets deployed to all users.
πŸ‘€ 1
d
their version and "install instructions" (the client script, html field script injection) is behind a subscription-wall... πŸ˜• Anyway, they add a z-index fix to make sure no edit-mode buttons (like "inventory detail" button, checkboxes, drop down) show through the header row, which is really nice (screenshot of the issue this fixed). Going back through my own script, I can't find why the mutation observer was needed. I think it was to accommodate when the machine table was slow to load
j
Hm. I wrote my own a few years back, it’s in SS1 😞 and is called from a client script.
Copy code
function freezeHeaders() {
  
	//console.log('----- FREEZE HEADERS: start');
	
	var current_context = nlapiGetContext(); 
	var execution_context = current_context.getExecutionContext();
	var user = current_context.user;
	
	// Not for (certain user with id 12345)
	if(user != 12345) {
		
		//console.log('----- FREEZE HEADERS: user: ' + user);
	
		jQuery(function () {
			
			const windowHeight = jQuery(window).height();
			
			//console.log('----- FREEZE HEADERS: windowHeight: ' + windowHeight);
	
		    jQuery('.uir-machine-table-container')
		      .filter((index, elem) => jQuery(elem).height() > windowHeight)
		      .css('height', '90vh')
		      .bind('scroll', (event) => {
		    	  const headerElem = jQuery(event.target).find('.uir-machine-headerrow');
		    	  //console.log('----- FREEZE HEADERS: before changing css');
		    	  headerElem.css('transform', 'translate(0, ' + (event.target.scrollTop - 1) + 'px)');
		    	  // console.log('----- FREEZE HEADERS: after changing css');
		      });
		});
		
	}
	
}
d
you can just run jQuery straight in SS1? Also, do you remember what the
-1
is for in:
Copy code
headerElem.css('transform', 'translate(0, ' + (event.target.scrollTop - 1) + 'px)');
It's just to give a little buffer between the header row and the data rows (maybe there's a tiny overlap?)