Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting name of checkbox in the dataview

Status
Not open for further replies.

mingus

Programmer
May 8, 2001
59
0
0
US
I am in rowGenerateBegin of a dataView.

I wish to have an onClick event that when I click anywhere on the row it toggles the checkbox that is on that row.

Problem: If I get the name of the checkbox:

String name = (String)CheckBox1.getProperty("NAME");

( OR

AgpTag x1 = getTag("CheckBox1");
String name = x1.getProperty("NAME"));
)

The name is not of the checkbox for the current row, but the row before. So when I click the checkbox that toggles is the one above where I really am.

So how can I get the name of checkbox for the current row?
Is this a bug, why would it give me the name before?

thanks


 
If I were you, I would bound the checkbox to table column and the column only record you have check the checkbox. Then I use a button to find(or loop through) all checkbox that is checked in that dataView. If I found it, I use "getCurrentRowCursor" to get property of that row and use SQL to do something(may be delete a row).

You can use a current row cursor object to get the property of current row:

AgiRowCursor cu = View1.getCurrentRowCursor();

Once you get the current row, you can get value.
Here is code for delete a row in dataView whenI click a button:

String[] ls_para = new String[2];
if (c.gotoFirst()==true){
//loop from first checkbox to last checkbox
do{
String c_storecode = (String)c.getProperty(sir + ".storecode");
String c_itemNumber = (String)c.getProperty(sir + ".item_num");
int c_status = ((Integer)(c.getProperty(sir + ".check"))).intValue();
if(c_status == 1){
//System.out.println("storecode = " + storecode);
ls_para[0] = "delete from " + sir + " where"
+ " " + sir + ".storecode = '" + c_storecode + "'"
+ " and " + sir + ".item_num = '" + c_itemNumber + "'";
ls_para[1] = "bossinian_informix";
this.invokeBusinessObject("sql_gen",ls_para);
}
}while (c.gotoNext()==true);
//agScriptHelper.alert("deleted");
View1.refreshRows();
}
 
Yes but if your DataView is 1,000 records you just looped 1,000 times.

I know your method is the "SilverStream way", but it also is very silly. Extra columns, extra looping, exta time. This is the very reason I don't like SilverStream!

It can take up to 4 seconds do loop though in one case where this was done, doing it differently can take less than a second. But SilverStream makes the alterative way hard to program and maintain.


mingus
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top