Is there a way to know if any row is selected or not?

I want to check with an if statement if something in the grid is select or if nothing is selected.
I tried this, but it didn’t work:

if ($('tr').hasClass(".ev_dhx_terrace")){

Any hints?

docs.dhtmlx.com/api__dhtmlxgrid_ … rowid.html

You may only use the getSelectedRowId() method, as Mindaugas mentioned.

The getSelectedRowId() gives a JS error if nothing is selected.

But I found out the correct code.
If you want to know if something is selected or nothing is selected use this:
if ($(‘tr’).hasClass(“rowselected”)){
do something when any row is selected
} else {
do something when no row is selected
}

Below is the code to get the checked row in checkbox being the first column and get the value of second column


var checkIds = myGrid.getCheckedRows(0);
    console.log("checkIds : "+ checkIds);
//check if only one row is selected.
	if ((checkIds.indexOf(",") == -1) && (checkIds!="")){
//Get value from second column of the checked row.
		var sId = myGrid.cells(checkIds,1).getValue().toString();
		console.log("Sel Id : "+ sId);
		$("#sId").val(sId);
	} else {
		alert("Please select a single row only.");
//alert user and uncheck all.
		myGrid.uncheckAll();
	}