Notifications
Announcements
No record found.
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
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.
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.
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.
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,
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?
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.
Thank you Leandro, This is the answer I need.
Under review
Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
Martin Dráb 4 Most Valuable Professional
Priya_K 4
MyDynamicsNAV 2