2017-03-24 3 views
1

Ich versuche, das Grid Excel und mit Hilfe der Exporter zu exportieren, es zu erreichen, Und mein Gitter ist hier Fiddle

Grid

Ext.application({ 
    name: 'Fiddle', 

    launch: function() { 
     Ext.create('Ext.data.Store', { 
      storeId: 'simpsonsStore', 
      fields: ['name', 'email', 'phone','date'], 
      data: { 
       'items': [{ 
        'name': 'Arshad11111', 
        "email": "[email protected]", 
        "phone": "6488646486", 
        "date":"2016-03-23" 
       }, { 
        'name': 'Aesadasdasd', 
        "email": "[email protected]", 
        "phone": "6488646486", 
        "date":"2016-03-23" 
       }, { 
        'name': 'gadjandna', 
        "email": "[email protected]", 
        "phone": "6488646486", 
        "date":"2016-03-23" 

       }, { 
        'name': 'asdasdasd', 
        "email": "[email protected]", 
        "phone": "555-222-1254", 
        "date": "2016-03-23" 
       }, ] 
      }, 
      proxy: { 
       type: 'memory', 
       reader: { 
        type: 'json', 
        root: 'items' 
       } 
      }, 
     }); 

     Ext.create('Ext.grid.Panel', { 
      title: 'Simpsons', 
      store: Ext.data.StoreManager.lookup('simpsonsStore'), 
      columns: [{ 
       text: 'Name', 
       dataIndex: 'name' 
      }, { 
       text: 'Email', 
       dataIndex: 'email', 
       flex: 1 
      }, { 
       text: 'Phone', 
       dataIndex: 'phone' 
      },{ 
       text: 'Date', 
       xtype: 'datecolumn', 
       dataIndex: 'telecastdate', 
       format: 'Y-m-d', 
       flex: 1 

      }], 

      height: 300, 
      width: 400, 
      dockedItems: [{ 
        xtype: 'toolbar', 
        docked: 'bottom', 
        items: [{ 
         xtype: 'button', 
         flex: 1, 
         text: 'Download to Excel', 
         handler: function (b, e) { 
          b.up('grid').downloadExcelXml(); 
         } 
        }] 
       } 

      ], 
      renderTo: Ext.getBody() 
     }); 
    } 
}); 

Es hat eine Spalte mit XType als Datumsspalte und in der Zeile von unten Raster zu Excel-Konverter, bekomme ich diese Uncaught TypeError: Cannot read property '$className' of undefined Fehler, aber wenn ich diese Datumsspalte entfernen, funktioniert es perfekt, So wie ich die Änderungen für die gleichen vornehmen,

switch (fld.$className) { 

        case "Ext.data.field.Integer": 
         console.log('Here Im typing 11111' + fld.$className); 
         cellType.push("Number"); 
         cellTypeClass.push("int"); 
         break; 
        case "Ext.data.field.Number": 
         console.log('Here Im typing 2222' + fld.$className); 
         cellType.push("Number"); 
         cellTypeClass.push("float"); 
         break; 
        case "Ext.data.field.Boolean": 
         console.log('Here Im typing 33333' + fld.$className); 
         cellType.push("String"); 
         cellTypeClass.push(""); 
         break; 
        case "Ext.data.field.Date": 
         console.log('Here Im typing 4444' + fld.$className); 
         cellType.push("DateTime"); 
         cellTypeClass.push("date"); 
         break; 
        default: 
         console.log('Here Im typing 555555555' + fld.$className); 
         cellType.push("String"); 
         cellTypeClass.push(""); 
         break; 
        } 
       } 

Vielen Dank im Voraus

Antwort

2

Es gibt eine falsche dataIndex im datecolumn ist. Der von Ihnen definierte Speicher hat nicht das Feld telecastdate sondern date. Wenn Sie telecastdate zu date ändern, funktioniert es.

Siehe den laufenden fiddle.

+1

Genau. oder anders herum. Stellen Sie 'telecastdate' auf Lager. zB: '{ 'name': 'asdasdasd', " email ":" [email protected] ", " Telefon ":" 555-222-1254 ", " telecastdate ":" 2016-03-23 " }' – UDID

+0

Ich habe es eilig verpasst. Schätze deine Hilfe Andy und auch @UDID –

Verwandte Themen