Check IF there are rows checked: grid.getCheckedRows(ind)

Hello,

I would like to check first if there are any rows checked and if there aren’t then alert the user that they must select at least one.

I have tried this:

...
var changes = myGrid1.getCheckedRows(9);
	alert(changes);
	if (changes !== 'undefined' && changes !== null) {
		alert("changes not null"+changes);
...

But, it doesn’t work. If I don’t select any rows, it still gets passed the “if” statement even though there is no rowid checked.

How can I check first if any rows are checked before doing something with the checked rows ids?

Many thanks in advance for your help!

Cheers,

Please, try to use:

if (changes!=null) {

instead of :

if (changes !== 'undefined' && changes !== null) {

Hello,

I have given that a try, but it still, even when there are no checked boxes, finds “changes != null” as true and does the code. I have tried “alert changes” and it is empty. So, I don’t know how I can accurately check if grid.getCheckedRows(ind) has any rows.

Any other ideas?

Many thanks again.

Hello,

I wanted to let you know that I was able to fix the problem with this:

if (changes) {

}

Many thanks for your help!

Cheers,