3.2.0

URGENT!!!! Get Column values for Selected Rows

I'm trying to get all column values from a list of selected rows.
There is a way to do it?

I did this but is not working.

function GetColumnBySelectedRows(Col, oGrid){
    
    var myRowsIndex = oGrid.getSelectedRows();
    alert(myRowsIndex);
    var mySelectedRowsIndex =  myRowsIndex.split(","); <-- problem here
    
    alert(mySelectedRowsIndex);
    //alert(oGrid.getData(0,SeletedRowsIndex));
    //var mySelectedRowsIndex = SeletedRowsIndex.split(",");
    //alert(mySelectedRowsIndex);
    var rowIndex, iIndex, rowColumnValue = "";
     
    for(iIndex=0; iIndex<aSelectedRowsIndex.length; iIndex++){ 
           rowIndex = aSelectedRowsIndex[iIndex]; 
        
      rowColumnValue += oGrid.getCellText(Col,rowIndex) + ","; 
    }
     
    return rowColumnValue; 
}



Any ideas?
Odimar Tomazeli
April 11,
Here a piece of a function I wrote to export all visible data. Hope this helps.

/**
 * function dataHandler_exportData(oDatagrid, aDatagridData, aDatagridColumns, bWYSIWYG)
 * 
 * + exports rows in dataGrid
 * 
 * @param  oDatagrid               object   ActiveWidget's grid 1.0 object
 * @param  aDatagridData           array    data represented in oDatagrid
 * @param  aDatagridColumns        array    array containing the column names
 * @param  bWYSIWYG                boolean  if set to true, only visible data is exported; default is TRUE                                                                      
 *                                 
 * @returns nothing       
 */   
function dataHandler_exportData(oDatagrid, aDatagridData, aDatagridColumns, bWYSIWYG)
{
  /* init */
  var aExportData    = new Array();
  var aExportColumns = new Array();
  var iColumnLength  = aDatagridColumns.length;
  var iRowLength     = aDatagridData.length;
  
  if (bWYSIWYG==null)
  {
    bWYSIWYG = true;
  } 
  /* get form */
  var oForm = document.getElementById(oDatagrid.name+'_actionForm');
  
  //save action and target
  sFormAction = oForm.action;
  sFormTarget = oForm.target;
  
  //change action and target
  oForm.action = 'Helper/exportTable.php?action='+iAction;
  oForm.target = '_blank';
  
  /* remove columns/data which arent visible */ 
  if (bWYSIWYG==true)
  {
    var aiVisibleColumnIndexes = oDatagrid.getColumnValues();
    
    //columns
    for (var j=iColumnLength-1; j>=0; j--)
    {
      if (aiVisibleColumnIndexes.indexOf(j)==-1)
      {
        //column is not visible: remove entry
        aDatagridColumns.splice(j,1);
      }
    }  
    
    //data
    for (var i=0; i<iRowLength; i++)
    {
      for (var j=iColumnLength-1; j>=0; j--)
      {      
        if (aiVisibleColumnIndexes.indexOf(j)==-1)
        {
          //column is not visible: remove entry
          aDatagridData[i].splice(j,1);
        } 
      }  
    }
  }  
       
  /* put columns and data in string */ 
  for (var i=0; i<iRowLength; i++) //walk through rows
  {    
    //add column data to export array
    aExportData[i] = encodeURIComponent(aDatagridData[i].join(','));      
  } 
  
(...)
}
Rekcor
April 11,
(hint: you must alter the last part of the code: my code walks through all rows, your code should walk to selected rows only; something like

/* get selected rows in grid */
var selectedRows = oDatagrid.getSelectionProperty("values");

for (i=0; i<selectedRows.length; i++)
{
  aExportData[i] = aDatagridData[selectedRows[i]].join(',');
}

)
Rekcor
April 11,
I'm gonna use this for sure!!! Thank you very much
Odimar Tomazeli
April 11,

This topic is archived.

See also:


Back to support forum