• If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Announcement

Collapse
No announcement yet.

[HELPED] Reading a grid to export to Excel - worked in 3.2 but not in 4.0

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • [HELPED] Reading a grid to export to Excel - worked in 3.2 but not in 4.0

    In migrating an app from 3.2 to 4.0 I have a piece that isn't working. It is an application that reads a grid to export it to Excel, I read the grid itself so that the Excel file has the same sorting as the user has on the grid at the moment. The code is below. I added the console.log() and it is showing 'theData' as undefined. Do I need to get the data from the grid in a different way now?

    Thanks,

    Scott

    Code:
        var exportToSS = function() {
            var theData = customerGrid.view.getRecords(customerGrid.view.getNodes());
            console.log(theData);
            
    		//  Build the JSON of the grid to send back to server.
    		stuff = '[';
    		Ext.Array.forEach(theData, function(item, index, allItems) {
    			stuff += '{"INVDCUST":'  + item.get('INVDCUST')  + 
    					 ',"TUNAME":'    + item.get('TUNAME')    + 
    					 ',"TOTALSUM":'  + item.get('TOTALSUM')  + 
    					 ',"DAYSTOPAY":' + item.get('DAYSTOPAY') + 
    					 ',"HOWMANY":'   + item.get('HOWMANY')   + 
    					 ',"RPM":'       + item.get('RPM')       + 
    					 ',"FSCRPM":'    + item.get('FSCRPM')    + 
    					 ',"LHRPM":'     + item.get('LHRPM')     + 
    					 '},';
    			}
    		);
    		stuff += ']';

  • #2
    Scott,

    You can gather the records from the grids store. The store will have the correct order based on how the user is sorting the grid.

    Example

    Code:
    var exportToSS = function() {
        var store = customerGrid.getStore(),
            count = store.getCount(),
            stuff = '[',
            rec;
    
        //gather the records
        //
        for (var ii=0; ii<count; ii++){
            rec = store.getAt(ii);
    
            stuff += '{"INVDCUST":'  + rec.get('INVDCUST')  +
                ',"TUNAME":'    + rec.get('TUNAME')    +
                ',"TOTALSUM":'  + rec.get('TOTALSUM')  +
                ',"DAYSTOPAY":' + rec.get('DAYSTOPAY') +
                ',"HOWMANY":'   + rec.get('HOWMANY')   +
                ',"RPM":'       + rec.get('RPM')       +
                ',"FSCRPM":'    + rec.get('FSCRPM')    +
                ',"LHRPM":'     + rec.get('LHRPM')     +
                '}';
    
            if (ii < (count - 1)){
                stuff += ',';
            }
        }
        stuff += ']';
    }

    Comment


    • #3
      Getting the records from the store worked great. For some reason when I originally created this app I was under the impression that the store wouldn't have the proper sort but it sure does. Either I made a mistake in my testing or something.

      Thanks for your help!

      Comment

      Working...
      X