Solved

Checkbox in datawindow

Posted on 2008-10-28
8
4,753 Views
Last Modified: 2013-12-26
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
Comment
Question by:coperations07
  • 5
  • 3
8 Comments
 
LVL 14

Accepted Solution

by:
sandeep_patel earned 400 total points
ID: 22832100
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
 

Author Comment

by:coperations07
ID: 22832444
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
 
LVL 14

Assisted Solution

by:sandeep_patel
sandeep_patel earned 400 total points
ID: 22835552
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
 
LVL 14

Expert Comment

by:sandeep_patel
ID: 22835575
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:coperations07
ID: 22841460
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
 
LVL 14

Assisted Solution

by:sandeep_patel
sandeep_patel earned 400 total points
ID: 22841756
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
 
LVL 14

Assisted Solution

by:sandeep_patel
sandeep_patel earned 400 total points
ID: 22841786
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
 

Author Comment

by:coperations07
ID: 22843965
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

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Programmer's Notepad is, one of the best free text editing tools available, simply because the developers appear to have second-guessed every weird problem or issue a programmer is likely to run into. One of these problems is selecting and deletiā€¦
Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now