Showing results for 
Search instead for 
Did you mean: 

Check TableView Row Selection in Javascript

Former Member
0 Kudos

Hi everyone,

I am trying to check in my javascript code if a row has been selected in my tableview. I looked at the discussion in the following thread:

I tried to use some of the methods suggested by in that thread but it doesn't seem to be working correctly.

Here is my javascript code:

function warn(){

var funcName = htmlb_formid+"_getHtmlbElementId";

func = window[funcName];

var table = eval(func("tblCalendarList"));

if(table.getSelectedRow() != null) {

var confirmed = window.confirm("You are about to permanently delete this record. To continue press OK");




else {

htmlbevent.cancelSubmit = true;




The code is supposed to check if a row is selected. If a row is selected, the code should through a warning message. In case no row is selected, the code should just continue submitting the form without throwing any messages.

I am not sure that I am correctly retrieving the tableview object.

Currently the code table.getSelectedRow() returns null whether or not a row is actually selected.

Accepted Solutions (0)

Answers (1)

Answers (1)

Active Contributor
0 Kudos

Hi Qasem,

Try to validate your tableview using this way.

<%@ taglib uri="tagLib" prefix="hbj" %>

<%@ page import="com.sapportals.htmlb.table.TableViewModel"%>

<SCRIPT language="javascript">

var flag = false;

function setFlag()


flag = true;


function checkFlag()


if(flag == false)


alert("Pls select a row!!");


return false;




<jsp:useBean id="Bean" scope="application" class="com.suresh.kb" />

<hbj:content id="myContext" >

<hbj:page title="PageTitle">

<hbj:form id="myFormId" >

<hbj:tableView id="myTableView"

design = "ALTERNATING"

headerVisible = "true"

footerVisible = "true"

fillUpEmptyRows = "true"

navigationMode = "BYLINE"

selectionMode = "SINGLESELECT"

headerText = "Selection"

onNavigate = "onNavigation"

visibleFirstRow = "<%= Bean.getVisibleRow() %>"

visibleRowCount = "2" >

<% myTableView.setModel(Bean.getModel()); %>

<% myTableView.setOnClientRowSelection("setFlag()"); %>

<% myTableView.setJsObjectNeeded(true); %>


<hbj:button id="submit"


tooltip="Click me to get detail"




jsObjectNeeded = "TRUE"

design="emphasized" />




Former Member
0 Kudos

Thanks Suresh for your answer...I haven't tried it yet but I think it will help me a work around.

What I wanted to do is be able to access the tableview object from within the javascript code so that I can call methods such as getSelectedRow() and getSelectedRowKey()

If you know how to access the tableview object from within javascript, I would really appreciate. The idea of providing sample code works great for me.