ComponentArt Grid – loop thru grid using javascript

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;
}

4 Comments

  1. 1
    sivanandam.M Says:

    it is very nice. it is working fine , thankyou lot….

  2. 2
    Duraisamy Says:

    Thank you very much. This code is more useful for me. Thanks a lot

  3. 3
    Anoop Says:

    When I do this I get the value as Undefined. can you tell me what the problem is?

    • 4
      bigidea Says:

      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.


RSS Feed for this entry

Leave a Comment