Operators MAX value

QuestionsOperators MAX value
GARY BRETT asked 7 years ago

Hi is it possible to format a row cell & column cell on Max values? For example read through a row/column and hi-lite the highest value?

I note the operators as eq', 'ne', 'lt', 'le', 'gt', 'ge', 'bw', 'bn', 'ew', 'en', 'cn', 'nc', 'nu', 'nn', 'in', 'ni' but cant see one for max value

4 Answers
Abu Ghufran answered 7 years ago

I've prepared a demo for min/max value conditional formatting.
This is done with JS code and only format what are on current page.

https://gist.github.com/gridphp/12895a38ff7681c4519fb461301bcadd
99,108-119,137-143

Gary answered 7 years ago

Fantastic Abu, really helpful to see the code. Can I ask what the 'ids' refers to ion this as I cannot make it work in any of my pages?

In my example below I have 12 columns, one for each month. I tried to test it on column name 'Jan' but that doesnt work?

<script>
function grid_onload(ids)
{
var low;
var low_index;
var high;
var high_index;

if(ids.rows)
jQuery.each(ids.rows,function(i)
{
// find lowest value
if (low == undefined || parseInt(this.Jan) < low)
{
low = parseInt(this.Jan);
low_index = i;
}

// find highest value
if (high == undefined || parseInt(this.Jan) > high)
{
high = parseInt(this.Jan);
high_index = i;
}
});

// highlight lowest client id
jQuery('#list1 tr.jqgrow:eq('+low_index+')').css('background-image','inherit');
jQuery('#list1 tr.jqgrow:eq('+low_index+') td[aria-describedby=list1_Jan]').css('background','inherit').css({'background-color':'#000', 'color':'white'});

// highlight highest client id
jQuery('#list1 tr.jqgrow:eq('+high_index+')').css('background-image','inherit');
jQuery('#list1 tr.jqgrow:eq('+high_index+') td[aria-describedby=list1_Jan]').css('background','inherit').css({'background-color':'red', 'color':'white'});
}
</script>

Gary answered 7 years ago

Hi Abu, please ignore my last post I figured it out, forgot to add the line $grid["loadComplete"] = "function(ids) { grid_onload(ids); }";

Apologies. Works great, if I want to use this on 12 columns would I need to recreate the script above for each column (1 per month, Jan, Feb, Mar etc etc etc

Abu Ghufran answered 7 years ago

I think yes. You will need all those variables for low/high of each column.

Please note this only apply on current page, not on all records of database table.
For all db records, some server side code would be required.

Your Answer

11 + 0 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?