• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 5800
  • Last Modified:

Checkbox in datawindow

Hi,
PB 10.5

I have a datawindow on a window that gets populated based on criteria that a user chooses.  I need some way of letting the user select certain rows that need to be deleted. I was trying to put a checkbox on the datawindow so that I could just loop through the dw and find the checked records upon a button click.  However, I haven't been able to figure out how to put a checkbox on the dw.
So...is there a way to put a functional checkbox on a datawindow? Or is there another way I should try to accomplish this?

Thanks,
Dave
0
coperations07
Asked:
coperations07
  • 5
  • 3
4 Solutions
 
sandeep_patelCommented:
you need to add computed column to your sql query.

1. open datawindow and from menu design > datasource
2. if it is in GUI mode, from menu design > convert to syntax
3. in your select statement add one more dummy column
(e.g. select emp_id,emp_name,' ' cf_flag from employee; here cf_flag is computed column)
4. Return to datawindow design, you will have new column
5. change it's edit style property.. property > edit tab > edit style...select checkbox

Done!!!

Regards,
Sandeep
0
 
coperations07Author Commented:
Okay. I've followed the steps and the checkbox is there, but I can't check it. Is there some other property I have to set so it can be checked? Also what will the value of the checkbox be if its checked or not? 1 or 0?

thx,
Dave
0
 
sandeep_patelCommented:
First you have to set the table order to make it editable (checked/unchecked). From menu.. Format > TabOrder and then set the order as per your checkbox position order.

Second to set the value for checked and unchecked...go to property of that column > edit tab > set property in 'Data Value for On' and 'Date Value for Off' and refer the same value in your script

Note: if where you retrieve it will be NULL so if you want to set it as default to 'Y' or 'N' change your sql from ' ' cf_flag to 'Y' cf_flag OR 'N' cf_flag (assuming 'Y' and 'N' for ON and OFF respectively)

Regards,
Sandeep
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

 
sandeep_patelCommented:
to correct "when you retrieve it will be NULL"....it won't be the NULL but one space string (' ').....hope you already got it but just to clear
0
 
coperations07Author Commented:
Okay. I think it's setup. But how do I get the checked state of the current row? I was trying to use getitemstring to see if the box was checked, but that just returns the data that is in the column that I used for the checkbox.
0
 
sandeep_patelCommented:
See my previous comment...I stated that refer the same value in script.

Means if say...
1. Data Value for On is set to 'Y' and Data Value for Off is set to 'N'
and now GetItemString for this column and row gives 'Y' then checkbox is checked if 'N' then unchecked in that row.

2. Data Value for On is set to '1' and Data Value for Off is set to '0'
and now GetItemString for this column and row gives '1' then checkbox is checked if '0' then unchecked in that row.

Like standard CheckBox control you can't use checked property here. Because it is a column but edit style is changed to display it as 'CheckBox'

Based on your required your code should be like this...

long ll_rowcount,ll_count
string ls_flag
ll_rowcount = dw_1.RowCount()
For ll_count = ll_rowcount to 1 step -1
     ls_flag = dw_1.object.cf_flag[ll_count]
     If ls_flag = 'Y' Then
          dw_1.DeleteRow(ll_count)
     End If
Next

Regards,
Sandeep



0
 
sandeep_patelCommented:
One more thing..Don't use any column which is already part of the table. You should use new dummy column as I told earlier.
0
 
coperations07Author Commented:
Okay. that's got me fixed up. I had an actual column in there instead of the dummy column. The checkbox was liking the quotes around "Y" and "N" either, so I had to remove those and now it works.

Thanks,
Dave
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now