Hi guys, I am trying to update a check box field in my grid by using a button clicked method.
How should I do it?
*This post is locked for comments
Thank you Leandro, This is the answer I need.
Hi,
I guess the problem is in markAllLoadedRecords(). It seems records in a grid are progressively loaded (retrieved from database) as you scroll it.
Instead of markAllLoadedRecords, try this:
<Table> record;
for (record = <dataSource>_ds.getFirst(); record; record = <dataSource>_ds.getNext())
{
...
}
<dataSource>_ds.research(true);
If your code isn't dependant on filters set on the datasource, You can update the table directly with a while select forupdate.
You could also retrieve the query from <datasource>_ds.queryRun() and retrieve the records with it. This will work similarly to the code I posted above.
Regards,
Hi Steeve,
Below is my code:
void clicked()
{
int i;
xinit_CustomerDet custdet;
;
super();
xinit_CustomerDet_ds.markAllLoadedRecords(1);
custdet = xinit_CustomerDet_ds.getFirst(true);
while (custdet)
{
custdet.Active = NoYes::Yes;
custdet.write();
custdet = xinit_CustomerDet_ds.getNext();
}
xinit_CustomerDet_ds.research(true);
}
I can updated the record but it did not updated all. In my grid, i have over 100 records, it always updated until half of it. And i have to click again button to trigger the function and update. Is there any solution to solve this?
In addition to Steeve's guidance, you can use <datasourcename>_ds.research() only once at the end of the process to update the display of all modified records.
Regards,
Use <datasourcename>_ds.getFirst() and <datasourcename>_ds.getNext() to browse the record. Modify each record and call write() so save the change. You will maybe need to call <datasourcename>_ds.refresh too see the change on the form.
Hi Pvanstilpelen,
I only can updated the first record. How about if I have 10 records in the grid view?
I am using "<datasourcename>.<fieldname> = NoYes::Yes" this code.
If your checkbox is bound to a datafield you can put following code in your clicked method
<datasourcename>.<fieldname> = NoYes::Yes
If it is not bound to a datafield and the name of your checkbox column is for instance ValueChecked put following code in your clicked method on the button
ValueChecked.Value(1);
In the properties of the ValueChecked checkbox, set AutoDeclaration to YES to be able to use it in the coding.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,188 Super User 2024 Season 2
Martin Dráb 230,030 Most Valuable Professional
nmaenpaa 101,156