3.2.0

help please retreiving data from Array into GRID URGENT

Hi guys,

I'm trying to retreive data in array format directly from a CGI programa into a Grid, I'm be able to retreive de data but I'm not able to display the data on the grid. any idea?

var tbBankStatement = [];

var r = new AW.HTTP.Request; 
r.setURL("http://server/application.cgi/getdata"); 
r.setRequestMethod("GET"); 
r.setParameter("UID", 1231); 
r.setParameter("type", 0); 
r.setParameter("op", 0); 
r.request(); 

r.response = function(data){ 
  var x = csvIntoAWArray(data,"|",",");
  tbBankStatement = eval(x);
}

  var BankStatementColumns = ["Id Statement", "Bank #", "Account #", "Backdated", "Date", "Description", "Currency", "Debit $", "Credit $", "Balance $", "Counterpart", "Transaction Type", "Bank Reference", "Customer Reference"];
  
  var ogridBankStatement = new AW.UI.Grid;
      ogridBankStatement.setId("gridBankStatement");
      ogridBankStatement.setHeaderText(BankStatementColumns);
      ogridBankStatement.setColumnCount(BankStatementColumns.length);
      
      //	set data formats
      ogridBankStatement.setCellFormat([integer, string, string, date, string, number, number]);
      //	set row selection
      ogridBankStatement.setSelectionMode("multi-row"); 

      //	enable row selectors
      ogridBankStatement.setSelectorVisible(true);
      ogridBankStatement.setSelectorText(function(i){return this.getRowPosition(i)});
      ogridBankStatement.setSelectorWidth(2);
    
      ogridBankStatement.setSelectorTemplate(new AW.Templates.CheckedItem); 

  
      ogridBankStatement.onSelectedRowsChanged = function(rowIndexArray){ 
                            var rowIndex, rowPosition, i, s = ""; 
 						        for(i=0; i<rowIndexArray.length; i++){ 
                                        rowIndex = rowIndexArray[i]; 
                                        rowPosition = this.getRowPosition(rowIndex); 
                                        s += rowPosition + ","; 
                                } 
        				oInField.setControlText(s); 
                        oInField.refresh();
      }
    
 
    
  //	provide external model as a grid data source
    
    
  var value = ogridBankStatement.getSortColumn(); 
      ogridBankStatement.setSortColumn(value);  
    
 ogridBankStatement.setRowCount(tbBankStatement.length-1);
 ogridBankStatement.setCellData(tbBankStatement);

 ogridBankStatement.refresh();


thanks
Odimar Tomazeli
April 4,
The AW.HTTP.Request makes asynchronous request by default. It could be that you execute setCellData(tbBankStatement) before the data arrives. Either use setAsync(true) or put the setup code into response() callback.
Alex (ActiveWidgets)
April 5,

This topic is archived.

See also:


Back to support forum