Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
475
Get grid cell value in javascript
posted

Hi,

I'm implementing a function (copy grid data to clipboard) that requires all grid values in a javascript. First, I looked examples and cannot find one. Second i looked document and cannot find instructioin. I looked into infragistic installed directory, and find some javascripts, use trial and error to find out each function. Is there better way? Where is complete document for using objects?

But I'm still having problems. I'm able to get cell object, but I don't know how to get value. Here is how I get all cells:

function copyButtonClicked() {

    var elm = document.getElementById('clipboardFormId:gridViewId'); // grid component id
    if(elm!=null)
    {
        var mygrid=ig.grid.getGrid(elm);
        if(!ig.isNull(mygrid))
        {
            var gridbody = mygrid.getBody();
            if(!ig.isNull(gridbody))
            {
               for(i=0; i<mygrid.getRowCount(); i++)
               {
                 for(j=0; j<mygrid.getColCount(); j++)
                 {
                   var cell=gridbody.getCell(i, j);

                   .....

                }

}
 

I'm stucked here, I don't know what to do with object cell. How to get the value? I somehow get the innerHTML:

cell.elm.innerHTML

But it is not the value and somehow I cannot get column title.

I'm trying to find document for row, col and cell object function. I cannot find any. The online examples are not sufficient.

Please Help

Thanks

Yan

Parents
  • 19693
    Verified Answer
    posted

    Hello, Yan
    You should create a new IgGridCell and after that you can use method get_value() or get_text() :
     for(j=0; j<mygrid.getColCount(); j++)
        {
                       var cell=gridbody.getCell(i, j);
           var newCell = new IgGridCell(cell.elm);
           var text = newCell.get_text();
           var value = newCell.get_value();
           }

    The js file "igf_grid.js" contains js functions conected with the grid .

     

     

Reply Children
No Data