0

When I iterate over grid.selection parameter (widget dgrid**) then it just gives me first value inside grid.selection and then it becomes null also the selection inside grid is getting lost. How can I avoid this? Is there any parameter through which I can avoid this behavior?

**http://www.sitepen.com/blog/2011/10/26/introducing-the-next-grid-dgrid/

mschr
  • 8,531
  • 3
  • 21
  • 35
TechnoCrat
  • 2,055
  • 4
  • 23
  • 35
  • whats a 'gridFromHtml' ? supply some code or its very difficult to give any aid – mschr Oct 03 '12 at 20:00
  • @mschr: Edited the question. Basically I am making use of dgrid. (http://www.sitepen.com/blog/2011/10/26/introducing-the-next-grid-dgrid/) – TechnoCrat Oct 05 '12 at 04:39

1 Answers1

0

I believe that grid.selection is an object hash of rows selected (rowNo => bool).

For iteration of an object, you could use following loop:

for(var attrName in grid.selection) {
    // some browsers also include prototypes (natives), avoid these like this
    if(grid.selection.hasOwnProperty(attrName) && grid.selection[attrName] == true) {
        selectedRowIter = grid.row(parseInt(attrName));
        // there's the data
    }
}

Hope it proves useful :)

mschr
  • 8,531
  • 3
  • 21
  • 35