on 08-08-2005 4:45 PM
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");
if(confirmed){
document.all.<%=buttonDelete%>.click();
}
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.
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!!");
htmlbevent.cancelSubmit="true";
return false;
}
}
</SCRIPT>
<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:tableView>
<hbj:button id="submit"
text="Details!"
tooltip="Click me to get detail"
disabled="false"
onClick="DetailPressed"
onClientClick="checkFlag()"
jsObjectNeeded = "TRUE"
design="emphasized" />
</hbj:form>
</hbj:page>
</hbj:content>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
User | Count |
---|---|
75 | |
9 | |
8 | |
7 | |
7 | |
6 | |
6 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.