This js function allows us to loop thru records in an componentart grid and check if a checkbox element is checked or not.
function CheckItems()
{
var grid=cagrid; // cagrid is the id of the componentart grid
var gridItem;
var itemIndex = 0;
var checked = false;
while(gridItem = grid.Table.GetRow(itemIndex))
{
if (gridItem.Cells[0].Value) // 0 is the 1st column as it is of checkbox type in this case
{
checked=true;
}
itemIndex++;
}
if (!checked)
{
alert(‘You have not selected any items.\n Please select atleast one item.’);
}
return checked;
}
it is very nice. it is working fine , thankyou lot….
Thank you very much. This code is more useful for me. Thanks a lot
When I do this I get the value as Undefined. can you tell me what the problem is?
any undefined error indicates the script can’t access instance of that object, most likely the componentart grid itself in this case. you need to debug to find where it fails.