You are viewing limited content. For full access, please sign in.

Question

Question

Hhighlight a row based on a word

asked on August 31, 2017 Show version history

I was helped last year with getting a row highlighted based on a value. And I'm now applying it to a word. It's working fine but it only runs when I click inside of a cell. I need to run after the information has been populated. I will be initiating this form from workflow using the invoke business process. Here is the code I have so far. 

$(document).ready(function(){

	$('.cf-table-block').on('blur', 'input', highlight);

	function highlight(){
		$('.cf-table-block tbody tr').each(function(){

			var currentWord = "";

			currentWord = $(this).find('.word input').val();

			if (currentWord == "Delivery")
				$(this).closest('tr').css("background", "limegreen");
		});
	}

});

Thanks for your help!

EDIT: I've tried removing the blur from the second line and loading another document.ready function but that hasn't worked.

0 0

Replies

replied on August 31, 2017 Show version history

Try using the following instead

$('.cf-table-block').change(function(){
    highlight();
})

blur only triggers when you click away, and input doesn't seem to work reliably since your handler is watching the table and not actual fields.

0 0
replied on August 31, 2017

I put that before and after the function and no go. It is still doing it only when I exit the cell. 

0 0
replied on August 31, 2017 Show version history

The change event is only going to fire when the user commits the change, i.e., exiting the field. If you want it to fire right away, you'll have to use a keypress or keyup event instead to have it check as the user is typing.-

EDIT: Use .keyup instead of .change and it should work the way you want. Keypress won't work right because it will fire before the value is added to the field.

$('.cf-table-block').keyup(function(){
    highlight();
})

 

0 0
replied on August 31, 2017

No one will write in this form. It's all auto generated by the workflow activity. So I need it to look after the fields are inserted and highlight automatically. Like how conditional highlighting works in Excel. 

0 0
replied on August 31, 2017 Show version history

If the fields are already populated when the form loads, have you tried just firing the highlight function on document ready like so,

 $(document).ready(function(){
    highlight();
});

function highlight(){
    //your code here
}

If that doesn't work try adding a slight delay by calling highlight(); within a setTimeOut.

0 0
replied on August 31, 2017

I'll give this a try and get back to you. I think I've tried this already but I'm not sure. I tried a lot of things.

0 0
replied on September 1, 2017

So they decided to have a user task in-between the storing of the document. I modified the code to this 

$(document).ready(function(){
	$('.cf-table-block tbody tr').each(function(){
		var currentWord = "";
		currentWord = $(this).find('.word input').val();

		if (currentWord == "Delivery" || currentWord == "Drop Empty"
				|| currentWord == "Relay" || currentWord == "Bobtail"
				|| currentWord == "Other" || currentWord == "Pickup")
				$(this).closest('tr').css("background", "limegreen");
		});
});

And it's working just fine when they load up their user task. Thanks for all your help Jason!

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.