Skip to content

Get grid cell value in javascript

New Discussion
Yan
Yan asked on Jul 23, 2009 3:07 PM

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

Sign In to post a reply

Replies

  • 0
    [Infragistics] Tsvetelina Georgieva
    [Infragistics] Tsvetelina Georgieva answered on Jul 21, 2009 10:09 AM

    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 .

     

     

    • 0
      Yan
      Yan answered on Jul 21, 2009 7:07 PM

      It worked.

      Thanks.

    • 0
      viswanath
      viswanath answered on Jul 23, 2009 3:07 PM

      Hi ,

       

      Here in this script code, how can we get the particular cell which i entered the value in that cell, i need to set the focus for that cell. Because i am loosing the focus of the cell, i want to put the cursor in the particular cell.

      Please send me the code. very very urgent.

       

      Thanks,

       

      A.Viswanath Yadav

  • 0
    [Infragistics]SGowdra
    [Infragistics]SGowdra answered on Jul 21, 2009 4:31 PM

    Hello yzbythesea, Here's one more way to get all the grid Values in javascript.

    function copyGridValues() {
      var rows = ig.grid.instances.myForm_grid.elm.childNodes[0].childNodes[1].rows;
      var i=0;
        while(i<rows.length) {
        var rowsCells = rows[i].childNodes;
        alert(rowsCells[0].childNodes[0].data +
        " " + rowsCells[1].childNodes[0].data +
        " " + rowsCells[2].childNodes[0].data +
        " " + rowsCells[3].childNodes[0].data);
        i++;
        }
    }

    Thank you!
    Swetha

  • You must be logged in to reply to this topic.
Discussion created by
Favorites
Replies
Created On
Last Post
Discussion created by
Yan
Favorites
0
Replies
4
Created On
Jul 23, 2009
Last Post
16 years, 7 months ago

Suggested Discussions

Created by

Yan

Created on

Jul 23, 2009 3:07 PM

Last activity on

Feb 11, 2026 8:35 AM