WebStudioSC
Posts: 7
|
Posted: 03/13/2012, 10:02 AM |
|
Does anyone have any code they could share with me to loop through each row in a grid when the user clicks a button? I'm looking for custom code that does this.
Thanks...
|
|
|
clahti2
Posts: 107
|
Posted: 03/13/2012, 10:22 AM |
|
Quote WebStudioSC:
Does anyone have any code they could share with me to loop through each row in a grid when the user clicks a button? I'm looking for custom code that does this.
Thanks...
That really depends on whether you want to loop through the current page, the whole record set, client side, server side. Can you be more specific on what you are trying to do?
|
|
|
WebStudioSC
Posts: 7
|
Posted: 03/13/2012, 10:29 AM |
|
I just want to loop through whole record set using severside scripting.
For an example, i may have an update checkbox on every row in my grid. after the my client pages through all the pages on the grid, they then want to hit an 'Update Selected' button where i update the completed date for each record that has the checkbox checked.
|
|
|
clahti2
Posts: 107
|
Posted: 03/13/2012, 10:47 AM |
|
this would be accomplished via the grid Before Build Update event. Assuming your checkbox is $updateme on grid $mygrid
if ($mygrid->updateme->GetValue() == 1) {
//the checkbox has been checked
//do some stuff
//if you want to suppress the actual update
$mygrid->DataSource->updateme->SetDBValue(0);
$mygrid->updateme->SetValue(0);
$mygrid->DataSource->CmdExecution = false;
}
The above will execute for every grid record you checked off. I am assuming this is an update grid.
|
|
|
DataDoIT
|
Posted: 03/13/2012, 1:33 PM |
|
Use the Delete checkbox to handle the selection of each record to act
upon. Make sure you have at least a hidden field in the editable grid
row for your primary key field. Then, for the grid's Button_Submit, use
custom code:
//We're not really deleting the record.
$Container->DeleteAllowed = false;
//Cycle through each shown row.
foreach ($Container->FormParameters['CheckBox_Delete'] as $key=>$value) {
//Cycle through only the checked rows.
if ($value != "") {
$PrimaryKey = $Container->CachedColumns["PrimaryKeyField"][$key];
//Do whatever per checked row. Access any input fields via
//the CachedColumns array.
}
}
This only works on returned and shown rows on the screen (ie: by page).
|
|
|
Waspman
Posts: 948
|
Posted: 03/15/2012, 3:00 AM |
|
couldn't you just add a checkbox and do an insert allowed thingy on condition of being checked. Why loop through?
Like clahti2 said
_________________
http://www.waspmedia.co.uk |
|
|