Devv
Devv

Reputation: 1

Export all records from grid in ax 2012 r2

I want to export data from grid in ax 2012 r2, but i want to export the grid in runtime. For example, if i have filter and only one record is showed the exported csv file should contain only that record. If there aren't any filters the exported csv file should contain all records from the grid.

Any idea how achieve this ?

I tried this code and it works but it's so slow and sometimes crashes or some rows a missing. The following code loop through all records in the grid. The variable numRows is number of records in the datasource table, this is also bad approach because if we have filter in the grid won't be presented same number as in the data source table.

  for(j = 1 ; j <= numRows; j++)
    {
        try
            {
                s = formGridControl.getLineData(j);
            }
        catch
            {
                infolog.clear();
                break;
            }

          arr = s.value('lines');
          tempArray = arr.value(1);
    for(z=2; z<=tempArray.lastIndex(); z++)
    {
        finalArray = tempArray.value(z);
        line2+=[finalArray];
    }
          row = this.parseContainer1(line2,separator);
          tempFile.write(row);
          line2 = conNull();
    }

Upvotes: 0

Views: 134

Answers (0)

Related Questions