cancel
Showing results for 
Search instead for 
Did you mean: 

onClientRowSelection for tableView's

Former Member
0 Kudos

Hi,

I'm working on a portal application which utalises epcf eventing to allow an iView to send messages another iView. Basically a table is displayed in the left iView and, depending which row the user selects, a message containing data from the selected row is sent to the right iView.

I initialy tried to utalise the onClientRowSelection('javascript') feature of the tableView htmlb element (with selectionMode="SINGLESELECT") which is supposed to invoke a javascrip function whose name is supplied as a parameter. However, after spending some time fudging trying to get it working, I was eventually took another route and turned one of the cells into a link.

I was wondering whether anyone else has had any experience using onClientRowSelection and were successful in calling some javascript.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Thanks Detlev,

That helps. I was doing something along the lines of:

<script language="JavaScript">

function onRowSelect(eventObj){

alert("Received message from" + eventObj.sourceID + ":" + eventObj.dataObject);

}

</script>

<hbj:tableView

id="myTableView"

.....

width="200"

onNavigate="onNavigate">

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

.....

</hbj:tableView>

Thinking that the setOnClientRowSelection would invoke the onRowSelect function in the javascript.

One more question...

I'd like to use this approach to raise an epcf event i.e.

myTableView.setOnClientRowSelection("EPCM.raiseEvent(<urn>, <eventName>, <objectData>, <sourseID> )");

would you by any chance know how to pass data from the selected row to <objectData>?

detlev_beutner
Active Contributor
0 Kudos

Hi Sergio,

> Thinking that the setOnClientRowSelection would

> invoke the onRowSelect function in the javascript.

The event object exists, it's not passed, see below.

> how to pass data from the selected row

> to <objectData>?

<%@ taglib uri="tagLib" prefix="hbj" %>
<jsp:useBean id="model" scope="application" class="com.sapportals.htmlb.table.DefaultTableViewModel" />
<%@ page import="com.sapportals.htmlb.TreeNode"%>
<hbj:content id="contentID" >
  <hbj:page title="pageTitle">
    <hbj:form id="formID" >
      <hbj:tableView
        id="myTableView"
        selectionMode="SINGLESELECT"
        model="model"
      >
        <% myTableView.setOnClientRowSelection("showUpTableContent()"); %>
        <% myTableView.setJsObjectNeeded(true); %>
      </hbj:tableView>
    </hbj:form>
  </hbj:page>
  <script language='JavaScript'>
  function showUpTableContent(){
    alert('it was a row ' + htmlbevent.obj.getClickedRow());
  }
  </script>
</hbj:content>

See https://forums.sdn.sap.com/thread.jspa?threadID=26395 for methods which exist on HTMLB TableView JS object. To retrieve a certain value, set the key column in your table.

Hope it helps

Detlev

Answers (1)

Answers (1)

detlev_beutner
Active Contributor
0 Kudos

Hi Sergio,

there is no problem at all:

<%@ taglib uri="tagLib" prefix="hbj" %>
<jsp:useBean id="model" scope="application" class="com.sapportals.htmlb.table.DefaultTableViewModel" />
<%@ page import="com.sapportals.htmlb.TreeNode"%>
<hbj:content id="contentID" >
  <hbj:page title="pageTitle">
    <hbj:form id="formID" >
      <hbj:tableView
        id="myTableView"
        selectionMode="SINGLESELECT"
        model="model"
      >
        <% myTableView.setOnClientRowSelection("alert('hurrah, a row has been selected')"); %>
      </hbj:tableView>
    </hbj:form>   		
  </hbj:page>
</hbj:content>

... just works.

Hope it helps

Detlev

PS: Please consider rewarding points. Thanks in advance!