Gelmiş geçmiş en büyük porno sitemiz olan 2pe de her zaman en kaliteli pornoları sunmayı hedefledik. Diğer video sitemiz olan vuam da ise hd porno ağırlıklı çalışmalara başladık.

  1. #51
    Ext JS Premium Member SMMJ_Dev's Avatar
    Join Date
    Aug 2009
    Location
    St. Louis, MO
    Posts
    88
    Vote Rating
    0
    SMMJ_Dev will become famous soon enough

      0  

    Default


    Yeah, I see the problem. It looks like in the code when they are creating a button they are Extending Ext.Button instead of Ext.button.Button.

    Also this does not work in IE due to IE's restrictions on data urls. What I did to get around this is posted the XML back to the server and had the server export an excel document.


    Code:
    /****  Base64 encode / decode*  http://www.webtoolkit.info/***/(function() {    // private property    var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";    // private method for UTF-8 encoding    function utf8Encode(string) {        string = string.replace(/\r\n/g,"\n");        var utftext = "";        for (var n = 0; n < string.length; n++) {            var c = string.charCodeAt(n);            if (c < 128) {                utftext += String.fromCharCode(c);            }            else if((c > 127) && (c < 2048)) {                utftext += String.fromCharCode((c >> 6) | 192);                utftext += String.fromCharCode((c & 63) | 128);            }            else {                utftext += String.fromCharCode((c >> 12) | 224);                utftext += String.fromCharCode(((c >> 6) & 63) | 128);                utftext += String.fromCharCode((c & 63) | 128);            }        }        return utftext;    }    Ext.define("Ext.ux.exporter.Base64", {        statics: {        //This was the original line, which tries to use Firefox's built in Base64 encoder, but this kept throwing exceptions....        // encode : (typeof btoa == 'function') ? function(input) { return btoa(input); } : function (input) {        encode : function (input) {            var output = "";            var chr1, chr2, chr3, enc1, enc2, enc3, enc4;            var i = 0;            input = utf8Encode(input);            while (i < input.length) {                chr1 = input.charCodeAt(i++);                chr2 = input.charCodeAt(i++);                chr3 = input.charCodeAt(i++);                enc1 = chr1 >> 2;                enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);                enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);                enc4 = chr3 & 63;                if (isNaN(chr2)) {                    enc3 = enc4 = 64;                } else if (isNaN(chr3)) {                    enc4 = 64;                }                output = output +                keyStr.charAt(enc1) + keyStr.charAt(enc2) +                keyStr.charAt(enc3) + keyStr.charAt(enc4);            }            return output;        }}    });})();/** * @class Ext.ux.Exporter * @author Ed Spencer (http://edspencer.net), with modifications from iwiznia. * Class providing a common way of downloading data in .xls or .csv format */Ext.define("Ext.ux.exporter.Exporter", {    uses: [        "Ext.ux.exporter.Base64",        "Ext.ux.exporter.Button",        "Ext.ux.exporter.csvFormatter.CsvFormatter",        "Ext.ux.exporter.excelFormatter.ExcelFormatter"    ],    statics: {        exportAny: function(component, formatter, config) {            var func = "export";            if(!component.is) {                func = func + "Store";            } else if(component.is("gridpanel")) {                func = func + "Grid";            } else if (component.is("treepanel")) {                func = func + "Tree";            } else {                func = func + "Store";                component = component.getStore();            }            return this[func](component, formatter, config);        },        /**         * Exports a grid, using the .xls formatter by default         * @param {Ext.grid.GridPanel} grid The grid to export from         * @param {Object} config Optional config settings for the formatter         */        exportGrid: function(grid, formatter, config) {          config = config || {};          formatter = formatter || new Ext.ux.exporter.excelFormatter.ExcelFormatter();          var columns = Ext.Array.filter(grid.columns, function(col) {              if(col.xtype){                  return !col.hidden && col.xtype != "actioncolumn";              }              return !col.hidden;          });          Ext.applyIf(config, {            title  : grid.title,            columns: columns          });          return Ext.ux.exporter.Base64.encode(formatter.format(grid.store, config));        },        exportStore: function(store, formatter, config) {           config = config || {};           formatter = formatter || new Ext.ux.exporter.excelFormatter.ExcelFormatter();           Ext.applyIf(config, {             columns: store.fields ? store.fields.items : store.model.prototype.fields.items           });           return Ext.ux.exporter.Base64.encode(formatter.format(store, config));        },        exportTree: function(tree, formatter, config) {          config    = config || {};          formatter = formatter || new Ext.ux.exporter.excelFormatter.ExcelFormatter();          var store = tree.store || config.store;          Ext.applyIf(config, {            title: tree.title          });          return Ext.ux.exporter.Base64.encode(formatter.format(store, config));        }    }});/** * @class Ext.ux.Exporter.Button * @extends Ext.Button * @author Nige White, with modifications from Ed Spencer, with modifications from iwiznia. * Specialised Button class that allows downloading of data via data: urls. * Internally, this is just a link. * Pass it either an Ext.Component subclass with a 'store' property, or just a store or nothing and it will try to grab the first parent of this button that is a grid or tree panel: * new Ext.ux.Exporter.Button({component: someGrid}); * new Ext.ux.Exporter.Button({store: someStore}); * @cfg {Ext.Component} component The component the store is bound to * @cfg {Ext.data.Store} store The store to export (alternatively, pass a component with a getStore method) */Ext.define("Ext.ux.exporter.Button", {    extend: "Ext.button.Button",    alias: "widget.exporterbutton",    constructor: function(config) {      config = config || {};      Ext.applyIf(config, {        disabled      : true,        text          : 'Download',        cls           : 'download',        href          : "/"      });      Ext.ux.exporter.Button.superclass.constructor.call(this, config);      if (this.store || this.component) {          this.setComponent(this.store || this.component, config);      } else {          var self = this;          this.on("render", function() { // We wait for the combo to be rendered, so we can look up to grab the component containing it              self.setComponent(self.up("gridpanel") || self.up("treepanel"), config);          });      }    },    setComponent: function(component, config) {        this.component = component;        this.store = !component.is ? component : component.getStore(); // only components or stores, if it doesn't respond to is method, it's a store        var setLink = function() {          var newConf = Ext.clone(config);          this.el.query('a', true)[0].href = 'data:application/vnd.ms-excel;base64,' + Ext.ux.exporter.Exporter.exportAny(this.component, null, newConf);          this.enable();        };        var me = this;        this.store.on("load", setLink, this);        if(Ext.ComponentQuery.is(this.component, "gridpanel")) {            Ext.Array.each(this.component.columns, function(col) {                col.on("show", setLink, me);                col.on("hide", setLink, me);            });        }    },    onClick : function(e){        if (e.button != 0) return;        if (!this.disabled){          this.fireEvent("click", this, e);          if (this.handler) this.handler.call(this.scope || this, this, e);        }    }});/** * @class Ext.ux.Exporter.Formatter * @author Ed Spencer (http://edspencer.net) * @cfg {Ext.data.Store} store The store to export */Ext.define("Ext.ux.exporter.Formatter", {    /**     * Performs the actual formatting. This must be overridden by a subclass     */    format: Ext.emptyFn,    constructor: function(config) {        config = config || {};        Ext.applyIf(config, {        });    }});/** * @class Ext.ux.Exporter.ExcelFormatter * @extends Ext.ux.Exporter.Formatter * Specialised Format class for outputting .xls files */Ext.define("Ext.ux.exporter.excelFormatter.ExcelFormatter", {    extend: "Ext.ux.exporter.Formatter",    uses: [        "Ext.ux.exporter.excelFormatter.Cell",        "Ext.ux.exporter.excelFormatter.Style",        "Ext.ux.exporter.excelFormatter.Worksheet",        "Ext.ux.exporter.excelFormatter.Workbook"    ],    format: function(store, config) {      var workbook = new Ext.ux.exporter.excelFormatter.Workbook(config);      workbook.addWorksheet(store, config || {});      return workbook.render();    }});/** * @class Ext.ux.Exporter.ExcelFormatter.Workbook * @extends Object * Represents an Excel workbook */Ext.define("Ext.ux.exporter.excelFormatter.Workbook", {  constructor: function(config) {    config = config || {};    Ext.apply(this, config, {      /**       * @property title       * @type String       * The title of the workbook (defaults to "Workbook")       */      title: "Workbook",      /**       * @property worksheets       * @type Array       * The array of worksheets inside this workbook       */      worksheets: [],      /**       * @property compileWorksheets       * @type Array       * Array of all rendered Worksheets       */      compiledWorksheets: [],      /**       * @property cellBorderColor       * @type String       * The colour of border to use for each Cell       */      cellBorderColor: "#e4e4e4",      /**       * @property styles       * @type Array       * The array of Ext.ux.Exporter.ExcelFormatter.Style objects attached to this workbook       */      styles: [],      /**       * @property compiledStyles       * @type Array       * Array of all rendered Ext.ux.Exporter.ExcelFormatter.Style objects for this workbook       */      compiledStyles: [],      /**       * @property hasDefaultStyle       * @type Boolean       * True to add the default styling options to all cells (defaults to true)       */      hasDefaultStyle: true,      /**       * @property hasStripeStyles       * @type Boolean       * True to add the striping styles (defaults to true)       */      hasStripeStyles: true,      windowHeight    : 9000,      windowWidth     : 50000,      protectStructure: false,      protectWindows  : false    });    if (this.hasDefaultStyle) this.addDefaultStyle();    if (this.hasStripeStyles) this.addStripedStyles();    this.addTitleStyle();    this.addHeaderStyle();  },  render: function() {    this.compileStyles();    this.joinedCompiledStyles = this.compiledStyles.join("");    this.compileWorksheets();    this.joinedWorksheets = this.compiledWorksheets.join("");    return this.tpl.apply(this);  },  /**   * Adds a worksheet to this workbook based on a store and optional config   * @param {Ext.data.Store} store The store to initialize the worksheet with   * @param {Object} config Optional config object   * @return {Ext.ux.Exporter.ExcelFormatter.Worksheet} The worksheet   */  addWorksheet: function(store, config) {    var worksheet = new Ext.ux.exporter.excelFormatter.Worksheet(store, config);    this.worksheets.push(worksheet);    return worksheet;  },  /**   * Adds a new Ext.ux.Exporter.ExcelFormatter.Style to this Workbook   * @param {Object} config The style config, passed to the Style constructor (required)   */  addStyle: function(config) {    var style = new Ext.ux.exporter.excelFormatter.Style(config || {});    this.styles.push(style);    return style;  },  /**   * Compiles each Style attached to this Workbook by rendering it   * @return {Array} The compiled styles array   */  compileStyles: function() {    this.compiledStyles = [];    Ext.each(this.styles, function(style) {      this.compiledStyles.push(style.render());    }, this);    return this.compiledStyles;  },  /**   * Compiles each Worksheet attached to this Workbook by rendering it   * @return {Array} The compiled worksheets array   */  compileWorksheets: function() {    this.compiledWorksheets = [];    Ext.each(this.worksheets, function(worksheet) {      this.compiledWorksheets.push(worksheet.render());    }, this);    return this.compiledWorksheets;  },  tpl: new Ext.XTemplate(    '<?xml version="1.0" encoding="utf-8"?>',    '<ss:Workbook xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:o="urn:schemas-microsoft-com:office:office">',      '<o:DocumentProperties>',        '<o:Title>{title}</o:Title>',      '</o:DocumentProperties>',      '<ss:ExcelWorkbook>',        '<ss:WindowHeight>{windowHeight}</ss:WindowHeight>',        '<ss:WindowWidth>{windowWidth}</ss:WindowWidth>',        '<ss:ProtectStructure>{protectStructure}</ss:ProtectStructure>',        '<ss:ProtectWindows>{protectWindows}</ss:ProtectWindows>',      '</ss:ExcelWorkbook>',      '<ss:Styles>',        '{joinedCompiledStyles}',      '</ss:Styles>',        '{joinedWorksheets}',    '</ss:Workbook>'  ),  /**   * Adds the default Style to this workbook. This sets the default font face and size, as well as cell borders   */  addDefaultStyle: function() {    var borderProperties = [      {name: "Color",     value: this.cellBorderColor},      {name: "Weight",    value: "1"},      {name: "LineStyle", value: "Continuous"}    ];    this.addStyle({      id: 'Default',      attributes: [        {          name: "Alignment",          properties: [            {name: "Vertical", value: "Top"},            {name: "WrapText", value: "1"}          ]        },        {          name: "Font",          properties: [            {name: "FontName", value: "arial"},            {name: "Size",     value: "10"}          ]        },        {name: "Interior"}, {name: "NumberFormat"}, {name: "Protection"},        {          name: "Borders",          children: [            {              name: "Border",              properties: [{name: "Position", value: "Top"}].concat(borderProperties)            },            {              name: "Border",              properties: [{name: "Position", value: "Bottom"}].concat(borderProperties)            },            {              name: "Border",              properties: [{name: "Position", value: "Left"}].concat(borderProperties)            },            {              name: "Border",              properties: [{name: "Position", value: "Right"}].concat(borderProperties)            }          ]        }      ]    });  },  addTitleStyle: function() {    this.addStyle({      id: "title",      attributes: [        {name: "Borders"},        {name: "Font"},        {          name: "NumberFormat",          properties: [            {name: "Format", value: "@"}          ]        },        {          name: "Alignment",          properties: [            {name: "WrapText",   value: "1"},            {name: "Horizontal", value: "Center"},            {name: "Vertical",   value: "Center"}          ]        }      ]    });  },  addHeaderStyle: function() {    this.addStyle({      id: "headercell",      attributes: [        {          name: "Font",          properties: [            {name: "Bold", value: "1"},            {name: "Size", value: "10"}          ]        },        {          name: "Interior",          properties: [            {name: "Pattern", value: "Solid"},            {name: "Color",   value: "#A3C9F1"}          ]        },        {          name: "Alignment",          properties: [            {name: "WrapText",   value: "1"},            {name: "Horizontal", value: "Center"}          ]        }      ]    });  },  /**   * Adds the default striping styles to this workbook   */  addStripedStyles: function() {    this.addStyle({      id: "even",      attributes: [        {          name: "Interior",          properties: [            {name: "Pattern", value: "Solid"},            {name: "Color",   value: "#CCFFFF"}          ]        }      ]    });    this.addStyle({      id: "odd",      attributes: [        {          name: "Interior",          properties: [            {name: "Pattern", value: "Solid"},            {name: "Color",   value: "#CCCCFF"}          ]        }      ]    });    Ext.each(['even', 'odd'], function(parentStyle) {      this.addChildNumberFormatStyle(parentStyle, parentStyle + 'date', "[ENG][$-409]dd\-mmm\-yyyy;@");      this.addChildNumberFormatStyle(parentStyle, parentStyle + 'int', "0");      this.addChildNumberFormatStyle(parentStyle, parentStyle + 'float', "0.00");    }, this);  },  /**   * Private convenience function to easily add a NumberFormat style for a given parentStyle   * @param {String} parentStyle The ID of the parentStyle Style   * @param {String} id The ID of the new style   * @param {String} value The value of the NumberFormat's Format property   */  addChildNumberFormatStyle: function(parentStyle, id, value) {    this.addStyle({      id: id,      parentStyle: "even",      attributes: [        {          name: "NumberFormat",          properties: [{name: "Format", value: value}]        }      ]    });  }});/** * @class Ext.ux.Exporter.ExcelFormatter.Worksheet * @extends Object * Represents an Excel worksheet * @cfg {Ext.data.Store} store The store to use (required) */Ext.define("Ext.ux.exporter.excelFormatter.Worksheet", {  constructor: function(store, config) {    config = config || {};    this.store = store;    Ext.applyIf(config, {      hasTitle   : true,      hasHeadings: true,      stripeRows : true,      title      : "Workbook",      columns    : store.fields == undefined ? {} : store.fields.items    });    Ext.apply(this, config);    Ext.ux.exporter.excelFormatter.Worksheet.superclass.constructor.apply(this, arguments);  },  /**   * @property dateFormatString   * @type String   * String used to format dates (defaults to "Y-m-d"). All other data types are left unmolested   */  dateFormatString: "Y-m-d",  worksheetTpl: new Ext.XTemplate(    '<ss:Worksheet ss:Name="{title}">',      '<ss:Names>',        '<ss:NamedRange ss:Name="Print_Titles" ss:RefersTo="=\'{title}\'!R1:R2" />',      '</ss:Names>',      '<ss:Table x:FullRows="1" x:FullColumns="1" ss:ExpandedColumnCount="{colCount}" ss:ExpandedRowCount="{rowCount}">',        '{columns}',        '<ss:Row ss:Height="38">',            '<ss:Cell ss:StyleID="title" ss:MergeAcross="{colCount - 1}">',              '<ss:Data xmlns:html="http://www.w3.org/TR/REC-html40" ss:Type="String">',                '<html:B><html:U><html:Font html:Size="15">{title}',                '</html:Font></html:U></html:B></ss:Data><ss:NamedCell ss:Name="Print_Titles" />',            '</ss:Cell>',        '</ss:Row>',        '<ss:Row ss:AutoFitHeight="1">',          '{header}',        '</ss:Row>',        '{rows}',      '</ss:Table>',      '<x:WorksheetOptions>',        '<x:PageSetup>',          '<x:Layout x:CenterHorizontal="1" x:Orientation="Landscape" />',          '<x:Footer x:Data="Page &amp;P of &amp;N" x:Margin="0.5" />',          '<x:PageMargins x:Top="0.5" x:Right="0.5" x:Left="0.5" x:Bottom="0.8" />',        '</x:PageSetup>',        '<x:FitToPage />',        '<x:Print>',          '<x:PrintErrors>Blank</x:PrintErrors>',          '<x:FitWidth>1</x:FitWidth>',          '<x:FitHeight>32767</x:FitHeight>',          '<x:ValidPrinterInfo />',          '<x:VerticalResolution>600</x:VerticalResolution>',        '</x:Print>',        '<x:Selected />',        '<x:DoNotDisplayGridlines />',        '<x:ProtectObjects>False</x:ProtectObjects>',        '<x:ProtectScenarios>False</x:ProtectScenarios>',      '</x:WorksheetOptions>',    '</ss:Worksheet>'  ),  /**   * Builds the Worksheet XML   * @param {Ext.data.Store} store The store to build from   */  render: function(store) {    return this.worksheetTpl.apply({      header  : this.buildHeader(),      columns : this.buildColumns().join(""),      rows    : this.buildRows().join(""),      colCount: this.columns.length,      rowCount: this.store.getCount() + 2,      title   : this.title    });  },  buildColumns: function() {    var cols = [];    Ext.each(this.columns, function(column) {      cols.push(this.buildColumn());    }, this);    return cols;  },  buildColumn: function(width) {    return Ext.String.format('<ss:Column ss:AutoFitWidth="1" ss:Width="{0}" />', width || 164);  },  buildRows: function() {    var rows = [];    this.store.each(function(record, index) {      rows.push(this.buildRow(record, index));    }, this);    return rows;  },  buildHeader: function() {    var cells = [];    Ext.each(this.columns, function(col) {      var title;      //if(col.dataIndex) {          if (col.text != undefined) {            title = col.text;          } else if(col.name) {            //make columns taken from Record fields (e.g. with a col.name) human-readable            title = col.name.replace(/_/g, " ");            title = title.charAt(0).toUpperCase() + title.substr(1).toLowerCase();          }          cells.push(Ext.String.format('<ss:Cell ss:StyleID="headercell"><ss:Data ss:Type="String">{0}</ss:Data><ss:NamedCell ss:Name="Print_Titles" /></ss:Cell>', title));      //}    }, this);    return cells.join("");  },  buildRow: function(record, index) {    var style,        cells = [];    if (this.stripeRows === true) style = index % 2 == 0 ? 'even' : 'odd';    Ext.each(this.columns, function(col) {      var name  = col.name || col.dataIndex;      if(name) {          //if given a renderer via a ColumnModel, use it and ensure data type is set to String          if (Ext.isFunction(col.renderer)) {            var value = col.renderer(record.get(name), null, record),                type = "String";          } else {            var value = record.get(name),                type  = this.typeMappings[col.type || record.fields.get(name).type.type];          }          cells.push(this.buildCell(value, type, style).render());      }    }, this);    return Ext.String.format("<ss:Row>{0}</ss:Row>", cells.join(""));  },  buildCell: function(value, type, style) {    if (type == "DateTime" && Ext.isFunction(value.format)) value = value.format(this.dateFormatString);    return new Ext.ux.exporter.excelFormatter.Cell({      value: value,      type : type,      style: style    });  },  /**   * @property typeMappings   * @type Object   * Mappings from Ext.data.Record types to Excel types   */  typeMappings: {    'int'   : "Number",    'string': "String",    'float' : "Number",    'date'  : "DateTime"  }});/** * @class Ext.ux.Exporter.ExcelFormatter.Cell * @extends Object * Represents a single cell in a worksheet */Ext.define("Ext.ux.exporter.excelFormatter.Cell", {    constructor: function(config) {        Ext.applyIf(config, {          type: "String"        });        Ext.apply(this, config);        Ext.ux.exporter.excelFormatter.Cell.superclass.constructor.apply(this, arguments);    },    render: function() {        return this.tpl.apply(this);    },    tpl: new Ext.XTemplate(        '<ss:Cell ss:StyleID="{style}">',          '<ss:Data ss:Type="{type}"><=!=[=C=D=A=T=A=[{value}]=]=></ss:Data>',        '</ss:Cell>'    )});/** * @class Ext.ux.Exporter.ExcelFormatter.Style * @extends Object * Represents a style declaration for a Workbook (this is like defining CSS rules). Example: * * new Ext.ux.Exporter.ExcelFormatter.Style({ *   attributes: [ *     { *       name: "Alignment", *       properties: [ *         {name: "Vertical", value: "Top"}, *         {name: "WrapText", value: "1"} *       ] *     }, *     { *       name: "Borders", *       children: [ *         name: "Border", *         properties: [ *           {name: "Color", value: "#e4e4e4"}, *           {name: "Weight", value: "1"} *         ] *       ] *     } *   ] * }) * * @cfg {String} id The ID of this style (required) * @cfg {Array} attributes The attributes for this style * @cfg {String} parentStyle The (optional parentStyle ID) */Ext.define("Ext.ux.exporter.excelFormatter.Style", {  constructor: function(config) {    config = config || {};    Ext.apply(this, config, {      parentStyle: '',      attributes : []    });    Ext.ux.exporter.excelFormatter.Style.superclass.constructor.apply(this, arguments);    if (this.id == undefined) throw new Error("An ID must be provided to Style");    this.preparePropertyStrings();  },  /**   * Iterates over the attributes in this style, and any children they may have, creating property   * strings on each suitable for use in the XTemplate   */  preparePropertyStrings: function() {    Ext.each(this.attributes, function(attr, index) {      this.attributes[index].propertiesString = this.buildPropertyString(attr);      this.attributes[index].children = attr.children || [];      Ext.each(attr.children, function(child, childIndex) {        this.attributes[index].children[childIndex].propertiesString = this.buildPropertyString(child);      }, this);    }, this);  },  /**   * Builds a concatenated property string for a given attribute, suitable for use in the XTemplate   */  buildPropertyString: function(attribute) {    var propertiesString = "";    Ext.each(attribute.properties || [], function(property) {      propertiesString += Ext.String.format('ss:{0}="{1}" ', property.name, property.value);    }, this);    return propertiesString;  },  render: function() {    return this.tpl.apply(this);  },  tpl: new Ext.XTemplate(    '<tpl if="parentStyle.length == 0">',      '<ss:Style ss:ID="{id}">',    '</tpl>',    '<tpl if="parentStyle.length != 0">',      '<ss:Style ss:ID="{id}" ss:Parent="{parentStyle}">',    '</tpl>',    '<tpl for="attributes">',      '<tpl if="children.length == 0">',        '<ss:{name} {propertiesString} />',      '</tpl>',      '<tpl if="children.length > 0">',        '<ss:{name} {propertiesString}>',          '<tpl for="children">',            '<ss:{name} {propertiesString} />',          '</tpl>',        '</ss:{name}>',      '</tpl>',    '</tpl>',    '</ss:Style>'  )});
    Try this new code
    Last edited by SMMJ_Dev; 21 Sep 2011 at 5:57 AM. Reason: adding code update
    ExtJS 4.0 - Ext.ux.grid.FooterSummary (Coming Soon)
    ExtJS 4.0 - Ext.ux.form.field.IPhoneSwitch (Coming Soon)
    ExtJS 4.0 - Ext.ux.grid.HeaderFilter
    (Updates Coming Soon)
    ExtJS 4.0 - Ext.ux.menu.DynamicMenu

    ExtJS 4.0 - Ext.ux.form.field.ClearableCombo
    ExtJS 4.0 - Ext.ux.form.field.FormPanelEditor
    ExtJS 4.0 - Grouping Extra Features (Overrides) (Updates Coming Soon)

  2. #52
    Sencha User semialcruz's Avatar
    Join Date
    May 2010
    Location
    Chapinlandia
    Posts
    12
    Vote Rating
    0
    semialcruz is on a distinguished road

      0  

    Default


    Same error... I tried everything yesterday and nothing seems to work

    I copy&paste your code and included on my index.php

    This is part of my code:
    GRID
    var gridPanel = Ext.create('Ext.grid.Panel', {
    flex: 0.60,
    store: store,
    id: 'store-form',
    title:'Datos de Cotizaciones',
    layout: 'fit',
    columns: [
    { text: 'Codigo', flex: 0.10, sortable: true, dataIndex: 'code', align: 'left' },
    { id: 'stores', text: 'Tienda', flex: 0.55, sortable: true, dataIndex: 'stores', align: 'left' },
    { text: 'Abiertas', flex: 0.15, sortable: true, dataIndex: 'opened', align: 'right', renderer: function(val){ return '<span style="color:#ff0000;">' + val + '</span>';} },
    { text: 'Cerradas', flex: 0.15, sortable: true, dataIndex: 'closed', align: 'right', renderer: function(val){ return '<span style="color:#318021;">' + val + '</span>';} },
    { text: 'Total Cotizaciones', flex: 0.15, sortable: true, dataIndex: 'quotes', align: 'right' }
    ],
    listeners: {
    selectionchange: function(model, records) {
    var json, name, i, l, items, series, fields;
    if (records[0]) {
    rec = records[0];
    form = form || this.up('form').getForm();
    fields = form.getFields();
    fields.each(function(field){ field.suspendEvents(); });
    form.loadRecord(rec);
    updateRecord(rec);
    fields.each(function(field){ field.resumeEvents(); });
    }
    }
    }
    });
    BUTTON
    var exportButton = new Ext.ux.Exporter.Button({
    component: gridPanel,
    text : "Download as .xls"
    });
    FORM
    var gridForm = Ext.create('Ext.form.Panel', {
    id: 'gridForm',
    title: 'Cotizaciones',
    frame: true,
    bodyPadding: 5,
    width: 870,
    height: 720,
    fieldDefaults: { labelAlign: 'left', msgTarget: 'side' },
    layout: { type: 'vbox',align: 'stretch' },
    items: [{
    height: 180,
    layout: 'fit',
    margin: '0 0 3 0',
    items: [barChart]
    },{
    layout: {type: 'hbox', align: 'stretch'},
    flex: 3,
    border: false,
    bodyStyle: 'background-color: transparent',
    items: [gridPanel, {
    flex: 0.4,
    layout: { type: 'vbox', align:'stretch' },
    margin: '0 0 0 5',
    title: 'Detalle de Cotizaciones',
    items: [{
    margin: '5',
    xtype: 'fieldset',
    flex: 1,
    title:'Detalle de Cotizaciones',
    defaults: { width: 240, labelWidth: 90 },
    defaultType: 'textfield',
    autoScroll: true,
    items: [
    { fieldLabel: 'Tienda', name: 'stores', disabled: true },
    { fieldLabel: 'Abiertas', name: 'opened' },
    { fieldLabel: 'Cerradas', name: 'closed' },
    { fieldLabel: 'Total', name: 'quotes' }
    ]
    },pieChart]
    }]
    }],
    dockedItems: [{
    xtype: 'toolbar',
    cls: 'absolute-form-toolbar',
    items: [{
    text: 'Exportar Excel',
    iconCls: 'icon-excel',
    handler: function() {
    alert('Exportando...');
    }
    },{
    text: 'Exportar PDF',
    iconCls: 'icon-pdf',
    handler: function() {
    alert('Exportando...');
    }
    },exportButton]
    }]
    });

  3. #53
    Ext JS Premium Member SMMJ_Dev's Avatar
    Join Date
    Aug 2009
    Location
    St. Louis, MO
    Posts
    88
    Vote Rating
    0
    SMMJ_Dev will become famous soon enough

      0  

    Default


    I looked at the button code, and it is still messed up.
    For now if you need this you can do what I'm currently doing.

    Replace your button code with a standard Ext.button.Button
    Code:
    Ext.create('Ext.button.Button',{
        text:'Download as .xls',
        handler:function(button){
            var gridPanel=button.up('gridpanel');
            var dataURL='data:application/vnd.ms-excel;base64,'+Ext.ux.exporter.Exporter.exportGrid(gridPanel);
            window.location.href=dataURL;
        }
    })
    ExtJS 4.0 - Ext.ux.grid.FooterSummary (Coming Soon)
    ExtJS 4.0 - Ext.ux.form.field.IPhoneSwitch (Coming Soon)
    ExtJS 4.0 - Ext.ux.grid.HeaderFilter
    (Updates Coming Soon)
    ExtJS 4.0 - Ext.ux.menu.DynamicMenu

    ExtJS 4.0 - Ext.ux.form.field.ClearableCombo
    ExtJS 4.0 - Ext.ux.form.field.FormPanelEditor
    ExtJS 4.0 - Grouping Extra Features (Overrides) (Updates Coming Soon)

  4. #54
    Ext JS Premium Member SMMJ_Dev's Avatar
    Join Date
    Aug 2009
    Location
    St. Louis, MO
    Posts
    88
    Vote Rating
    0
    SMMJ_Dev will become famous soon enough

      0  

    Default


    OK, I think I fixed it. Try out this as your Exporter-all.js. I finally put a test scenario together for you and fixed the button.

    Code:
    /**
    *
    *  Base64 encode / decode
    *  http://www.webtoolkit.info/
    *
    **/
    
    
    (function() {
    
    
        // private property
        var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
    
    
        // private method for UTF-8 encoding
        function utf8Encode(string) {
            string = string.replace(/\r\n/g,"\n");
            var utftext = "";
            for (var n = 0; n < string.length; n++) {
                var c = string.charCodeAt(n);
                if (c < 128) {
                    utftext += String.fromCharCode(c);
                }
                else if((c > 127) && (c < 2048)) {
                    utftext += String.fromCharCode((c >> 6) | 192);
                    utftext += String.fromCharCode((c & 63) | 128);
                }
                else {
                    utftext += String.fromCharCode((c >> 12) | 224);
                    utftext += String.fromCharCode(((c >> 6) & 63) | 128);
                    utftext += String.fromCharCode((c & 63) | 128);
                }
            }
            return utftext;
        }
    
    
        Ext.define("Ext.ux.exporter.Base64", {
            statics: {
            //This was the original line, which tries to use Firefox's built in Base64 encoder, but this kept throwing exceptions....
            // encode : (typeof btoa == 'function') ? function(input) { return btoa(input); } : function (input) {
            encode : function (input) {
                var output = "";
                var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
                var i = 0;
                input = utf8Encode(input);
                while (i < input.length) {
                    chr1 = input.charCodeAt(i++);
                    chr2 = input.charCodeAt(i++);
                    chr3 = input.charCodeAt(i++);
                    enc1 = chr1 >> 2;
                    enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
                    enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
                    enc4 = chr3 & 63;
                    if (isNaN(chr2)) {
                        enc3 = enc4 = 64;
                    } else if (isNaN(chr3)) {
                        enc4 = 64;
                    }
                    output = output +
                    keyStr.charAt(enc1) + keyStr.charAt(enc2) +
                    keyStr.charAt(enc3) + keyStr.charAt(enc4);
                }
                return output;
            }}
        });
    })();
    
    
    /**
     * @class Ext.ux.Exporter
     * @author Ed Spencer (http://edspencer.net), with modifications from iwiznia.
     * Class providing a common way of downloading data in .xls or .csv format
     */
    Ext.define("Ext.ux.exporter.Exporter", {
        uses: [
            "Ext.ux.exporter.Base64",
            "Ext.ux.exporter.Button",
            "Ext.ux.exporter.csvFormatter.CsvFormatter",
            "Ext.ux.exporter.excelFormatter.ExcelFormatter"
        ],
    
    
        statics: {
            exportAny: function(component, formatter, config) {
                var func = "export";
                if(!component.is) {
                    func = func + "Store";
                } else if(component.is("gridpanel")) {
                    func = func + "Grid";
                } else if (component.is("treepanel")) {
                    func = func + "Tree";
                } else {
                    func = func + "Store";
                    component = component.getStore();
                }
                return this[func](component, formatter, config);
            },
    
    
            /**
             * Exports a grid, using the .xls formatter by default
             * @param {Ext.grid.GridPanel} grid The grid to export from
             * @param {Object} config Optional config settings for the formatter
             */
            exportGrid: function(grid, formatter, config) {
              config = config || {};
              formatter = formatter || new Ext.ux.exporter.excelFormatter.ExcelFormatter();
              var columns = Ext.Array.filter(grid.columns, function(col) {
                  if(col.xtype){
                      return !col.hidden && col.xtype != "actioncolumn";
                  }
                  return !col.hidden;
              });
    
    
              Ext.applyIf(config, {
                title  : grid.title,
                columns: columns
              });
    
    
              return Ext.ux.exporter.Base64.encode(formatter.format(grid.store, config));
            },
    
    
            exportStore: function(store, formatter, config) {
               config = config || {};
               formatter = formatter || new Ext.ux.exporter.excelFormatter.ExcelFormatter();
    
    
               Ext.applyIf(config, {
                 columns: store.fields ? store.fields.items : store.model.prototype.fields.items
               });
    
    
               return Ext.ux.exporter.Base64.encode(formatter.format(store, config));
            },
    
    
            exportTree: function(tree, formatter, config) {
              config    = config || {};
              formatter = formatter || new Ext.ux.exporter.excelFormatter.ExcelFormatter();
    
    
              var store = tree.store || config.store;
    
    
              Ext.applyIf(config, {
                title: tree.title
              });
    
    
              return Ext.ux.exporter.Base64.encode(formatter.format(store, config));
            }
        }
    });
    
    
    /**
     * @class Ext.ux.Exporter.Button
     * @extends Ext.Button
     * @author Nige White, with modifications from Ed Spencer, with modifications from iwiznia.
     * Specialised Button class that allows downloading of data via data: urls.
     * Internally, this is just a link.
     * Pass it either an Ext.Component subclass with a 'store' property, or just a store or nothing and it will try to grab the first parent of this button that is a grid or tree panel:
     * new Ext.ux.Exporter.Button({component: someGrid});
     * new Ext.ux.Exporter.Button({store: someStore});
     * @cfg {Ext.Component} component The component the store is bound to
     * @cfg {Ext.data.Store} store The store to export (alternatively, pass a component with a getStore method)
     */
    Ext.define("Ext.ux.exporter.Button", {
        extend: "Ext.Button",
        alias: "widget.exporterbutton",
        initComponent: function(config) {
          var me=this;
          config = config || {};
    
    
          Ext.applyIf(config, {
            disabled      : true,
            text          : 'Download',
            cls           : 'download',
            href          : "/"
          });
          me.callParent(arguments);
    
    
          if (me.store || me.component) {
              me.setComponent(me.store || me.component, config);
          } else {
              var self = me;
              me.on("render", function() { // We wait for the combo to be rendered, so we can look up to grab the component containing it
                  self.setComponent(self.up("gridpanel") || self.up("treepanel"), config);
              });
          }
        },
    
    
        setComponent: function(component, config) {
            var me=this;
            me.component = component;
            me.store = !component.is ? component : component.getStore(); // only components or stores, if it doesn't respond to is method, it's a store
            var setLink = function() {
              var newConf=Ext.clone(config);
              me.handler=function(){
            	  window.location.href='data:application/vnd.ms-excel;base64,' + Ext.ux.exporter.Base64.encode(Ext.ux.exporter.Exporter.exportAny(me.component, null, newConf));
              }
              me.enable();
            };
    
    
            me.store.on("load", setLink, me);
            if(me.component.isXType){
    	        if(me.component.isXType("gridpanel")) {
    	            Ext.Array.each(me.component.columns, function(col) {
    	                col.on("show", setLink, me);
    	                col.on("hide", setLink, me);
    	            });
    	        }
            }
        },
    
    
        onClick : function(e){
        	var me=this;
            if (e.button != 0) return;
    
    
            if (!me.disabled){
              me.fireEvent("click", me, e);
    
    
              if (me.handler) me.handler.call(me.scope || me, me, e);
            }
        }
    });
    
    
    /**
     * @class Ext.ux.Exporter.Formatter
     * @author Ed Spencer (http://edspencer.net)
     * @cfg {Ext.data.Store} store The store to export
     */
    Ext.define("Ext.ux.exporter.Formatter", {
        /**
         * Performs the actual formatting. This must be overridden by a subclass
         */
        format: Ext.emptyFn,
        constructor: function(config) {
            config = config || {};
    
    
            Ext.applyIf(config, {
    
    
            });
        }
    });
    
    
    /**
     * @class Ext.ux.Exporter.ExcelFormatter
     * @extends Ext.ux.Exporter.Formatter
     * Specialised Format class for outputting .xls files
     */
    Ext.define("Ext.ux.exporter.excelFormatter.ExcelFormatter", {
        extend: "Ext.ux.exporter.Formatter",
        uses: [
            "Ext.ux.exporter.excelFormatter.Cell",
            "Ext.ux.exporter.excelFormatter.Style",
            "Ext.ux.exporter.excelFormatter.Worksheet",
            "Ext.ux.exporter.excelFormatter.Workbook"
        ],
    
    
        format: function(store, config) {
          var workbook = new Ext.ux.exporter.excelFormatter.Workbook(config);
          workbook.addWorksheet(store, config || {});
    
    
          return workbook.render();
        }
    });
    
    
    /**
     * @class Ext.ux.Exporter.ExcelFormatter.Workbook
     * @extends Object
     * Represents an Excel workbook
     */
    Ext.define("Ext.ux.exporter.excelFormatter.Workbook", {
    
    
      constructor: function(config) {
        config = config || {};
    
    
        Ext.apply(this, config, {
          /**
           * @property title
           * @type String
           * The title of the workbook (defaults to "Workbook")
           */
          title: "Workbook",
    
    
          /**
           * @property worksheets
           * @type Array
           * The array of worksheets inside this workbook
           */
          worksheets: [],
    
    
          /**
           * @property compileWorksheets
           * @type Array
           * Array of all rendered Worksheets
           */
          compiledWorksheets: [],
    
    
          /**
           * @property cellBorderColor
           * @type String
           * The colour of border to use for each Cell
           */
          cellBorderColor: "#e4e4e4",
    
    
          /**
           * @property styles
           * @type Array
           * The array of Ext.ux.Exporter.ExcelFormatter.Style objects attached to this workbook
           */
          styles: [],
    
    
          /**
           * @property compiledStyles
           * @type Array
           * Array of all rendered Ext.ux.Exporter.ExcelFormatter.Style objects for this workbook
           */
          compiledStyles: [],
    
    
          /**
           * @property hasDefaultStyle
           * @type Boolean
           * True to add the default styling options to all cells (defaults to true)
           */
          hasDefaultStyle: true,
    
    
          /**
           * @property hasStripeStyles
           * @type Boolean
           * True to add the striping styles (defaults to true)
           */
          hasStripeStyles: true,
    
    
          windowHeight    : 9000,
          windowWidth     : 50000,
          protectStructure: false,
          protectWindows  : false
        });
    
    
        if (this.hasDefaultStyle) this.addDefaultStyle();
        if (this.hasStripeStyles) this.addStripedStyles();
    
    
        this.addTitleStyle();
        this.addHeaderStyle();
      },
    
    
      render: function() {
        this.compileStyles();
        this.joinedCompiledStyles = this.compiledStyles.join("");
    
    
        this.compileWorksheets();
        this.joinedWorksheets = this.compiledWorksheets.join("");
    
    
        return this.tpl.apply(this);
      },
    
    
      /**
       * Adds a worksheet to this workbook based on a store and optional config
       * @param {Ext.data.Store} store The store to initialize the worksheet with
       * @param {Object} config Optional config object
       * @return {Ext.ux.Exporter.ExcelFormatter.Worksheet} The worksheet
       */
      addWorksheet: function(store, config) {
        var worksheet = new Ext.ux.exporter.excelFormatter.Worksheet(store, config);
    
    
        this.worksheets.push(worksheet);
    
    
        return worksheet;
      },
    
    
      /**
       * Adds a new Ext.ux.Exporter.ExcelFormatter.Style to this Workbook
       * @param {Object} config The style config, passed to the Style constructor (required)
       */
      addStyle: function(config) {
        var style = new Ext.ux.exporter.excelFormatter.Style(config || {});
    
    
        this.styles.push(style);
    
    
        return style;
      },
    
    
      /**
       * Compiles each Style attached to this Workbook by rendering it
       * @return {Array} The compiled styles array
       */
      compileStyles: function() {
        this.compiledStyles = [];
    
    
        Ext.each(this.styles, function(style) {
          this.compiledStyles.push(style.render());
        }, this);
    
    
        return this.compiledStyles;
      },
    
    
      /**
       * Compiles each Worksheet attached to this Workbook by rendering it
       * @return {Array} The compiled worksheets array
       */
      compileWorksheets: function() {
        this.compiledWorksheets = [];
    
    
        Ext.each(this.worksheets, function(worksheet) {
          this.compiledWorksheets.push(worksheet.render());
        }, this);
    
    
        return this.compiledWorksheets;
      },
    
    
      tpl: new Ext.XTemplate(
        '<?xml version="1.0" encoding="utf-8"?>',
        '<ss:Workbook xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:o="urn:schemas-microsoft-com:office:office">',
          '<o:DocumentProperties>',
            '<o:Title>{title}</o:Title>',
          '</o:DocumentProperties>',
          '<ss:ExcelWorkbook>',
            '<ss:WindowHeight>{windowHeight}</ss:WindowHeight>',
            '<ss:WindowWidth>{windowWidth}</ss:WindowWidth>',
            '<ss:ProtectStructure>{protectStructure}</ss:ProtectStructure>',
            '<ss:ProtectWindows>{protectWindows}</ss:ProtectWindows>',
          '</ss:ExcelWorkbook>',
          '<ss:Styles>',
            '{joinedCompiledStyles}',
          '</ss:Styles>',
            '{joinedWorksheets}',
        '</ss:Workbook>'
      ),
    
    
      /**
       * Adds the default Style to this workbook. This sets the default font face and size, as well as cell borders
       */
      addDefaultStyle: function() {
        var borderProperties = [
          {name: "Color",     value: this.cellBorderColor},
          {name: "Weight",    value: "1"},
          {name: "LineStyle", value: "Continuous"}
        ];
    
    
        this.addStyle({
          id: 'Default',
          attributes: [
            {
              name: "Alignment",
              properties: [
                {name: "Vertical", value: "Top"},
                {name: "WrapText", value: "1"}
              ]
            },
            {
              name: "Font",
              properties: [
                {name: "FontName", value: "arial"},
                {name: "Size",     value: "10"}
              ]
            },
            {name: "Interior"}, {name: "NumberFormat"}, {name: "Protection"},
            {
              name: "Borders",
              children: [
                {
                  name: "Border",
                  properties: [{name: "Position", value: "Top"}].concat(borderProperties)
                },
                {
                  name: "Border",
                  properties: [{name: "Position", value: "Bottom"}].concat(borderProperties)
                },
                {
                  name: "Border",
                  properties: [{name: "Position", value: "Left"}].concat(borderProperties)
                },
                {
                  name: "Border",
                  properties: [{name: "Position", value: "Right"}].concat(borderProperties)
                }
              ]
            }
          ]
        });
      },
    
    
      addTitleStyle: function() {
        this.addStyle({
          id: "title",
          attributes: [
            {name: "Borders"},
            {name: "Font"},
            {
              name: "NumberFormat",
              properties: [
                {name: "Format", value: "@"}
              ]
            },
            {
              name: "Alignment",
              properties: [
                {name: "WrapText",   value: "1"},
                {name: "Horizontal", value: "Center"},
                {name: "Vertical",   value: "Center"}
              ]
            }
          ]
        });
      },
    
    
      addHeaderStyle: function() {
        this.addStyle({
          id: "headercell",
          attributes: [
            {
              name: "Font",
              properties: [
                {name: "Bold", value: "1"},
                {name: "Size", value: "10"}
              ]
            },
            {
              name: "Interior",
              properties: [
                {name: "Pattern", value: "Solid"},
                {name: "Color",   value: "#A3C9F1"}
              ]
            },
            {
              name: "Alignment",
              properties: [
                {name: "WrapText",   value: "1"},
                {name: "Horizontal", value: "Center"}
              ]
            }
          ]
        });
      },
    
    
      /**
       * Adds the default striping styles to this workbook
       */
      addStripedStyles: function() {
        this.addStyle({
          id: "even",
          attributes: [
            {
              name: "Interior",
              properties: [
                {name: "Pattern", value: "Solid"},
                {name: "Color",   value: "#CCFFFF"}
              ]
            }
          ]
        });
    
    
        this.addStyle({
          id: "odd",
          attributes: [
            {
              name: "Interior",
              properties: [
                {name: "Pattern", value: "Solid"},
                {name: "Color",   value: "#CCCCFF"}
              ]
            }
          ]
        });
    
    
        Ext.each(['even', 'odd'], function(parentStyle) {
          this.addChildNumberFormatStyle(parentStyle, parentStyle + 'date', "[ENG][$-409]dd\-mmm\-yyyy;@");
          this.addChildNumberFormatStyle(parentStyle, parentStyle + 'int', "0");
          this.addChildNumberFormatStyle(parentStyle, parentStyle + 'float', "0.00");
        }, this);
      },
    
    
      /**
       * Private convenience function to easily add a NumberFormat style for a given parentStyle
       * @param {String} parentStyle The ID of the parentStyle Style
       * @param {String} id The ID of the new style
       * @param {String} value The value of the NumberFormat's Format property
       */
      addChildNumberFormatStyle: function(parentStyle, id, value) {
        this.addStyle({
          id: id,
          parentStyle: "even",
          attributes: [
            {
              name: "NumberFormat",
              properties: [{name: "Format", value: value}]
            }
          ]
        });
      }
    });
    
    
    /**
     * @class Ext.ux.Exporter.ExcelFormatter.Worksheet
     * @extends Object
     * Represents an Excel worksheet
     * @cfg {Ext.data.Store} store The store to use (required)
     */
    Ext.define("Ext.ux.exporter.excelFormatter.Worksheet", {
    
    
      constructor: function(store, config) {
        config = config || {};
    
    
        this.store = store;
    
    
        Ext.applyIf(config, {
          hasTitle   : true,
          hasHeadings: true,
          stripeRows : true,
    
    
          title      : "Workbook",
          columns    : store.fields == undefined ? {} : store.fields.items
        });
    
    
        Ext.apply(this, config);
    
    
        Ext.ux.exporter.excelFormatter.Worksheet.superclass.constructor.apply(this, arguments);
      },
    
    
      /**
       * @property dateFormatString
       * @type String
       * String used to format dates (defaults to "Y-m-d"). All other data types are left unmolested
       */
      dateFormatString: "Y-m-d",
    
    
      worksheetTpl: new Ext.XTemplate(
        '<ss:Worksheet ss:Name="{title}">',
          '<ss:Names>',
            '<ss:NamedRange ss:Name="Print_Titles" ss:RefersTo="=\'{title}\'!R1:R2" />',
          '</ss:Names>',
          '<ss:Table x:FullRows="1" x:FullColumns="1" ss:ExpandedColumnCount="{colCount}" ss:ExpandedRowCount="{rowCount}">',
            '{columns}',
            '<ss:Row ss:Height="38">',
                '<ss:Cell ss:StyleID="title" ss:MergeAcross="{colCount - 1}">',
                  '<ss:Data xmlns:html="http://www.w3.org/TR/REC-html40" ss:Type="String">',
                    '<html:B><html:U><html:Font html:Size="15">{title}',
                    '</html:Font></html:U></html:B></ss:Data><ss:NamedCell ss:Name="Print_Titles" />',
                '</ss:Cell>',
            '</ss:Row>',
            '<ss:Row ss:AutoFitHeight="1">',
              '{header}',
            '</ss:Row>',
            '{rows}',
          '</ss:Table>',
          '<x:WorksheetOptions>',
            '<x:PageSetup>',
              '<x:Layout x:CenterHorizontal="1" x:Orientation="Landscape" />',
              '<x:Footer x:Data="Page &amp;P of &amp;N" x:Margin="0.5" />',
              '<x:PageMargins x:Top="0.5" x:Right="0.5" x:Left="0.5" x:Bottom="0.8" />',
            '</x:PageSetup>',
            '<x:FitToPage />',
            '<x:Print>',
              '<x:PrintErrors>Blank</x:PrintErrors>',
              '<x:FitWidth>1</x:FitWidth>',
              '<x:FitHeight>32767</x:FitHeight>',
              '<x:ValidPrinterInfo />',
              '<x:VerticalResolution>600</x:VerticalResolution>',
            '</x:Print>',
            '<x:Selected />',
            '<x:DoNotDisplayGridlines />',
            '<x:ProtectObjects>False</x:ProtectObjects>',
            '<x:ProtectScenarios>False</x:ProtectScenarios>',
          '</x:WorksheetOptions>',
        '</ss:Worksheet>'
      ),
    
    
      /**
       * Builds the Worksheet XML
       * @param {Ext.data.Store} store The store to build from
       */
      render: function(store) {
        return this.worksheetTpl.apply({
          header  : this.buildHeader(),
          columns : this.buildColumns().join(""),
          rows    : this.buildRows().join(""),
          colCount: this.columns.length,
          rowCount: this.store.getCount() + 2,
          title   : this.title
        });
      },
    
    
      buildColumns: function() {
        var cols = [];
    
    
        Ext.each(this.columns, function(column) {
          cols.push(this.buildColumn());
        }, this);
    
    
        return cols;
      },
    
    
      buildColumn: function(width) {
        return Ext.String.format('<ss:Column ss:AutoFitWidth="1" ss:Width="{0}" />', width || 164);
      },
    
    
      buildRows: function() {
        var rows = [];
    
    
        this.store.each(function(record, index) {
          rows.push(this.buildRow(record, index));
        }, this);
    
    
        return rows;
      },
    
    
      buildHeader: function() {
        var cells = [];
    
    
        Ext.each(this.columns, function(col) {
          var title;
    
    
          //if(col.dataIndex) {
              if (col.text != undefined) {
                title = col.text;
              } else if(col.name) {
                //make columns taken from Record fields (e.g. with a col.name) human-readable
                title = col.name.replace(/_/g, " ");
                title = title.charAt(0).toUpperCase() + title.substr(1).toLowerCase();
              }
    
    
              cells.push(Ext.String.format('<ss:Cell ss:StyleID="headercell"><ss:Data ss:Type="String">{0}</ss:Data><ss:NamedCell ss:Name="Print_Titles" /></ss:Cell>', title));
          //}
        }, this);
    
    
        return cells.join("");
      },
    
    
      buildRow: function(record, index) {
        var style,
            cells = [];
        if (this.stripeRows === true) style = index % 2 == 0 ? 'even' : 'odd';
    
    
        Ext.each(this.columns, function(col) {
          var name  = col.name || col.dataIndex;
    
    
          if(name) {
              //if given a renderer via a ColumnModel, use it and ensure data type is set to String
              if (Ext.isFunction(col.renderer)) {
                var value = col.renderer(record.get(name), null, record),
                    type = "String";
              } else {
                var value = record.get(name),
                    type  = this.typeMappings[col.type || record.fields.get(name).type.type];
              }
    
    
              cells.push(this.buildCell(value, type, style).render());
          }
        }, this);
    
    
        return Ext.String.format("<ss:Row>{0}</ss:Row>", cells.join(""));
      },
    
    
      buildCell: function(value, type, style) {
        if (type == "DateTime" && Ext.isFunction(value.format)) value = value.format(this.dateFormatString);
    
    
        return new Ext.ux.exporter.excelFormatter.Cell({
          value: value,
          type : type,
          style: style
        });
      },
    
    
      /**
       * @property typeMappings
       * @type Object
       * Mappings from Ext.data.Record types to Excel types
       */
      typeMappings: {
        'int'   : "Number",
        'string': "String",
        'float' : "Number",
        'date'  : "DateTime"
      }
    });
    
    
    /**
     * @class Ext.ux.Exporter.ExcelFormatter.Cell
     * @extends Object
     * Represents a single cell in a worksheet
     */
    
    
    Ext.define("Ext.ux.exporter.excelFormatter.Cell", {
        constructor: function(config) {
            Ext.applyIf(config, {
              type: "String"
            });
    
    
            Ext.apply(this, config);
    
    
            Ext.ux.exporter.excelFormatter.Cell.superclass.constructor.apply(this, arguments);
        },
    
    
        render: function() {
            return this.tpl.apply(this);
        },
    
    
        tpl: new Ext.XTemplate(
            '<ss:Cell ss:StyleID="{style}">',
              '<ss:Data ss:Type="{type}"><![CDATA[{value}]]></ss:Data>',
            '</ss:Cell>'
        )
    });
    
    
    /**
     * @class Ext.ux.Exporter.ExcelFormatter.Style
     * @extends Object
     * Represents a style declaration for a Workbook (this is like defining CSS rules). Example:
     *
     * new Ext.ux.Exporter.ExcelFormatter.Style({
     *   attributes: [
     *     {
     *       name: "Alignment",
     *       properties: [
     *         {name: "Vertical", value: "Top"},
     *         {name: "WrapText", value: "1"}
     *       ]
     *     },
     *     {
     *       name: "Borders",
     *       children: [
     *         name: "Border",
     *         properties: [
     *           {name: "Color", value: "#e4e4e4"},
     *           {name: "Weight", value: "1"}
     *         ]
     *       ]
     *     }
     *   ]
     * })
     *
     * @cfg {String} id The ID of this style (required)
     * @cfg {Array} attributes The attributes for this style
     * @cfg {String} parentStyle The (optional parentStyle ID)
     */
    Ext.define("Ext.ux.exporter.excelFormatter.Style", {
      constructor: function(config) {
        config = config || {};
    
    
        Ext.apply(this, config, {
          parentStyle: '',
          attributes : []
        });
    
    
        Ext.ux.exporter.excelFormatter.Style.superclass.constructor.apply(this, arguments);
    
    
        if (this.id == undefined) throw new Error("An ID must be provided to Style");
    
    
        this.preparePropertyStrings();
      },
    
    
      /**
       * Iterates over the attributes in this style, and any children they may have, creating property
       * strings on each suitable for use in the XTemplate
       */
      preparePropertyStrings: function() {
        Ext.each(this.attributes, function(attr, index) {
          this.attributes[index].propertiesString = this.buildPropertyString(attr);
          this.attributes[index].children = attr.children || [];
    
    
          Ext.each(attr.children, function(child, childIndex) {
            this.attributes[index].children[childIndex].propertiesString = this.buildPropertyString(child);
          }, this);
        }, this);
      },
    
    
      /**
       * Builds a concatenated property string for a given attribute, suitable for use in the XTemplate
       */
      buildPropertyString: function(attribute) {
        var propertiesString = "";
    
    
        Ext.each(attribute.properties || [], function(property) {
          propertiesString += Ext.String.format('ss:{0}="{1}" ', property.name, property.value);
        }, this);
    
    
        return propertiesString;
      },
    
    
      render: function() {
        return this.tpl.apply(this);
      },
    
    
      tpl: new Ext.XTemplate(
        '<tpl if="parentStyle.length == 0">',
          '<ss:Style ss:ID="{id}">',
        '</tpl>',
        '<tpl if="parentStyle.length != 0">',
          '<ss:Style ss:ID="{id}" ss:Parent="{parentStyle}">',
        '</tpl>',
        '<tpl for="attributes">',
          '<tpl if="children.length == 0">',
            '<ss:{name} {propertiesString} />',
          '</tpl>',
          '<tpl if="children.length > 0">',
            '<ss:{name} {propertiesString}>',
              '<tpl for="children">',
                '<ss:{name} {propertiesString} />',
              '</tpl>',
            '</ss:{name}>',
          '</tpl>',
        '</tpl>',
        '</ss:Style>'
      )
    });
    ExtJS 4.0 - Ext.ux.grid.FooterSummary (Coming Soon)
    ExtJS 4.0 - Ext.ux.form.field.IPhoneSwitch (Coming Soon)
    ExtJS 4.0 - Ext.ux.grid.HeaderFilter
    (Updates Coming Soon)
    ExtJS 4.0 - Ext.ux.menu.DynamicMenu

    ExtJS 4.0 - Ext.ux.form.field.ClearableCombo
    ExtJS 4.0 - Ext.ux.form.field.FormPanelEditor
    ExtJS 4.0 - Grouping Extra Features (Overrides) (Updates Coming Soon)

  5. #55
    Touch Premium Member
    Join Date
    May 2011
    Posts
    48
    Vote Rating
    0
    RAD001 is on a distinguished road

      0  

    Default 'Downloadify' is undefined

    'Downloadify' is undefined


    Hi All,



    did anyone able to get this working??
    I am getting this error on FF and IE8
    Code:
    'Downloadify' is undefined
    any idea ???

  6. #56
    Sencha User
    Join Date
    Jun 2008
    Posts
    157
    Vote Rating
    0
    wiznia is on a distinguished road

      0  

    Default


    Ouch, I've been updating this yesterday and didn't have time to comment it in the documentation. I changed the downloading mechanism from data-uris to a flash based solution.
    The reason for that was:
    1) Some browsers didn't support data uris.
    2) There was a limit (I don't know exactly the number) on the size of the data uris that made the browsers crash when set.
    So, now it's based on downloadify, which is flash. So you need to include downloadify.min.js (supplied) and configure on the button, the paths to the
    swf and the image, this are the defaults:
    Code:
            swfPath: '/flash/downloadify.swf',
            downloadImage: '/images/ext_reports/download.png',
            width: 62,
            height: 22,        downloadName: "download"
    When I have a little time I will update the docs. Oh, and don't use the exporter-all.js since it's not updated I need to write a build script so it generates the minified version.
    Let me know if you encounter problems.

  7. #57
    Touch Premium Member
    Join Date
    May 2011
    Posts
    48
    Vote Rating
    0
    RAD001 is on a distinguished road

      0  

    Default


    Hi Wiznia,

    I did include the downloadify.min.js but then it complained about 'swfobject'
    So I downloaded the downloadify and included the swfobject as well

    here is my html
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Stateful Array Grid Example</title>
        <link rel="stylesheet" type="text/css" href="../../resources/css/ext-all.css" />
        <link rel="stylesheet" type="text/css" href="../shared/example.css" />
        <script type="text/javascript" src="../../bootstrap.js"></script>
          <script type="text/javascript" src="../ux/exporter/swfobject.js"></script>
          <script type="text/javascript" src="../ux/exporter/downloadify.min.js"></script>
        <!-- page specific -->
        <style type="text/css">
            /* style rows on mouseover */
            .x-grid-row-over .x-grid-cell-inner {
                font-weight: bold;
            }
            /* shared styles for the ActionColumn icons */
            .x-action-col-cell img {
                height: 16px;
                width: 16px;
                cursor: pointer;
            }
            /* custom icon for the "buy" ActionColumn icon */
            .x-action-col-cell img.buy-col {
                background-image: url(../shared/icons/fam/accept.png);
            }
            /* custom icon for the "alert" ActionColumn icon */
            .x-action-col-cell img.alert-col {
                background-image: url(../shared/icons/fam/error.png);
            }
            .x-ie6 .x-action-col-cell img.buy-col {
                background-image: url(../shared/icons/fam/accept.gif);
            }
            .x-ie6.x-action-col-cell img.alert-col {
                background-image: url(../shared/icons/fam/error.gif);
            }
            .x-ie6 .x-action-col-cell img {
                position:relative;
                top:-1px;
            }
        </style>
        <script type="text/javascript" src="array-grid.js"></script>
    </head>
    <body>
        <h1>Stateful Array Grid Example</h1>
        <p>This example shows how to create a grid from Array data.</p>
        <p>The grid is stateful so you can move or hide columns, reload the page, and come
        back to the grid in the same state you left it in.</p>
        <p>Note that the js is not minified so it is readable. See <a href="array-grid.js">array-grid.js</a>.</p>
        <div id="grid-example"></div>
    </body>
    </html>
    here is my js code
    Code:
     /*
    This file is part of Ext JS 4
    Copyright (c) 2011 Sencha Inc
    Contact:  http://www.sencha.com/contact
    Commercial Usage
    Licensees holding valid commercial licenses may use this file in accordance with the Commercial Software License Agreement provided with the Software or, alternatively, in accordance with the terms contained in a written agreement between you and Sencha.
    If you are unsure which license is appropriate for your use, please contact the sales department at http://www.sencha.com/contact.
    */
    Ext.Loader.setConfig({ enabled: true });
    Ext.Loader.setPath('Ext.ux.exporter','../ux/exporter');
    Ext.require([
        'Ext.grid.*',
        'Ext.data.*',
        'Ext.util.*',
        'Ext.state.*',
        'Ext.ux.exporter.Exporter.*',
    'Ext.ux.exporter.excelFormatter.*',
    'Ext.ux.exporter.csvFormatter.*'
    ]);
    Ext.onReady(function () {
        Ext.QuickTips.init();
        // setup the state provider, all state information will be saved to a cookie
        Ext.state.Manager.setProvider(Ext.create('Ext.state.CookieProvider'));
        // sample static data for the store
        var myData = [
            ['3m Co', 71.72, 0.02, 0.03, '9/1 12:00am'],
            ['Alcoa Inc', 29.01, 0.42, 1.47, '9/1 12:00am'],
            ['Altria Group Inc', 83.81, 0.28, 0.34, '9/1 12:00am'],
            ['American Express Company', 52.55, 0.01, 0.02, '9/1 12:00am'],
            ['American International Group, Inc.', 64.13, 0.31, 0.49, '9/1 12:00am'],
            ['AT&T Inc.', 31.61, -0.48, -1.54, '9/1 12:00am'],
            ['Boeing Co.', 75.43, 0.53, 0.71, '9/1 12:00am'],
            ['Caterpillar Inc.', 67.27, 0.92, 1.39, '9/1 12:00am'],
            ['Citigroup, Inc.', 49.37, 0.02, 0.04, '9/1 12:00am'],
            ['E.I. du Pont de Nemours and Company', 40.48, 0.51, 1.28, '9/1 12:00am'],
            ['Exxon Mobil Corp', 68.1, -0.43, -0.64, '9/1 12:00am'],
            ['General Electric Company', 34.14, -0.08, -0.23, '9/1 12:00am'],
            ['General Motors Corporation', 30.27, 1.09, 3.74, '9/1 12:00am'],
            ['Hewlett-Packard Co.', 36.53, -0.03, -0.08, '9/1 12:00am'],
            ['Honeywell Intl Inc', 38.77, 0.05, 0.13, '9/1 12:00am'],
            ['Intel Corporation', 19.88, 0.31, 1.58, '9/1 12:00am'],
            ['International Business Machines', 81.41, 0.44, 0.54, '9/1 12:00am'],
            ['Johnson & Johnson', 64.72, 0.06, 0.09, '9/1 12:00am'],
            ['JP Morgan & Chase & Co', 45.73, 0.07, 0.15, '9/1 12:00am'],
            ['McDonald\'s Corporation', 36.76, 0.86, 2.40, '9/1 12:00am'],
            ['Merck & Co., Inc.', 40.96, 0.41, 1.01, '9/1 12:00am'],
            ['Microsoft Corporation', 25.84, 0.14, 0.54, '9/1 12:00am'],
            ['Pfizer Inc', 27.96, 0.4, 1.45, '9/1 12:00am'],
            ['The Coca-Cola Company', 45.07, 0.26, 0.58, '9/1 12:00am'],
            ['The Home Depot, Inc.', 34.64, 0.35, 1.02, '9/1 12:00am'],
            ['The Procter & Gamble Company', 61.91, 0.01, 0.02, '9/1 12:00am'],
            ['United Technologies Corporation', 63.26, 0.55, 0.88, '9/1 12:00am'],
            ['Verizon Communications', 35.57, 0.39, 1.11, '9/1 12:00am'],
            ['Wal-Mart Stores, Inc.', 45.45, 0.73, 1.63, '9/1 12:00am']
        ];
        /**
        * Custom function used for column renderer
        * @param {Object} val
        */
        function change(val) {
            if (val > 0) {
                return '<span style="color:green;">' + val + '</span>';
            } else if (val < 0) {
                return '<span style="color:red;">' + val + '</span>';
            }
            return val;
        }
        /**
        * Custom function used for column renderer
        * @param {Object} val
        */
        function pctChange(val) {
            if (val > 0) {
                return '<span style="color:green;">' + val + '%</span>';
            } else if (val < 0) {
                return '<span style="color:red;">' + val + '%</span>';
            }
            return val;
        }
        // create the data store
        var store = Ext.create('Ext.data.ArrayStore', {
            fields: [
               { name: 'company' },
               { name: 'price', type: 'float' },
               { name: 'change', type: 'float' },
               { name: 'pctChange', type: 'float' },
               { name: 'lastChange', type: 'date', dateFormat: 'n/j h:ia' }
            ],
            data: myData
        });
        var exportButton = Ext.create('Ext.ux.exporter.Button', {
            component: Ext.getCmp('grid'),
            icon: '../ux/exporter/download.png',
            text: "export Excel"
        });
    
        // create the Grid
        var grid = Ext.create('Ext.grid.Panel', {
            store: store,
            stateful: true,
            stateId: 'stateGrid',
            columns: [
                {
                    text: 'Company',
                    flex: 1,
                    sortable: false,
                    dataIndex: 'company'
                },
                {
                    text: 'Price',
                    width: 75,
                    sortable: true,
                    renderer: 'usMoney',
                    dataIndex: 'price'
                },
                {
                    text: 'Change',
                    width: 75,
                    sortable: true,
                    renderer: change,
                    dataIndex: 'change'
                },
                {
                    text: '% Change',
                    width: 75,
                    sortable: true,
                    renderer: pctChange,
                    dataIndex: 'pctChange'
                },
                {
                    text: 'Last Updated',
                    width: 85,
                    sortable: true,
                    renderer: Ext.util.Format.dateRenderer('m/d/Y'),
                    dataIndex: 'lastChange'
                },
                {
                    xtype: 'actioncolumn',
                    width: 50,
                    items: [{
                        icon: '../shared/icons/fam/delete.gif',  // Use a URL in the icon config
                        tooltip: 'Sell stock',
                        handler: function (grid, rowIndex, colIndex) {
                            var rec = store.getAt(rowIndex);
                            alert("Sell " + rec.get('company'));
                        }
                    }, {
                        getClass: function (v, meta, rec) {          // Or return a class from a function
                            if (rec.get('change') < 0) {
                                this.items[1].tooltip = 'Hold stock';
                                return 'alert-col';
                            } else {
                                this.items[1].tooltip = 'Buy stock';
                                return 'buy-col';
                            }
                        },
                        handler: function (grid, rowIndex, colIndex) {
                            var rec = store.getAt(rowIndex);
                            alert((rec.get('change') < 0 ? "Hold " : "Buy ") + rec.get('company'));
                        }
                    }]
                }
            ],
            dockedItems: [{
                xtype: 'toolbar',
                //cls: 'absolute-form-toolbar',
                items: [{ xtype: 'exporterbutton'}]
            }]
    ,
            height: 350,
            width: 600,
            title: 'Array Grid',
            renderTo: 'grid-example',
            viewConfig: {
                stripeRows: true
            }
        });
    });
    since you have the download.png and downloadify.swf in the same dir
    I change the button config
    Code:
        config: {
            swfPath: 'downloadify.swf',
            downloadImage: 'download.png',
            width: 62,
            height: 22,
            downloadName: "download"
        },
    now I am not getting any error on both ie8 and ff but I don't see the button on the toolbar...
    am I missing something here????

  8. #58
    Sencha User
    Join Date
    Jun 2008
    Posts
    157
    Vote Rating
    0
    wiznia is on a distinguished road

      0  

    Default


    i'll try to put an example to clarify things, for now, here's what you need to do:
    - include swfobject2 (not incñuded)
    - include downloadify.min.hs
    - create an exporterButton with the appropriate configuration pointing to the image and the swf.
    - require with ext loader the Ext.ux.Exporter class.
    - don't you use the exporter-all file since it's outdated.

    don't forget to download the new code aince I updated it yesterday.
    I promise to put an example project and update the documentation, just give me some time.

  9. #59
    Touch Premium Member
    Join Date
    May 2011
    Posts
    48
    Vote Rating
    0
    RAD001 is on a distinguished road

      0  

    Default


    Hi Wiznia,

    thanks for the info but still it's not working for me.


    I am getting this.el is undefined
    Code:
            Downloadify.create(this.el.down('p').id,{
                filename: function() {
                  return self.getDownloadName() + "." + Ext.ux.exporter.Exporter.getFormatterByName(self.formatter).extension;
                },
                data: function() {
                  return Ext.ux.exporter.Exporter.exportAny(self.component, self.formatter, config);
                },
                transparent: false,
                swf: this.getSwfPath(),
                downloadImage: this.getDownloadImage(),
                width: this.getWidth(),
                height: this.getHeight(),
                transparent: true,
                append: false
            });


    here is my html
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Stateful Array Grid Example</title>
        <link rel="stylesheet" type="text/css" href="../../resources/css/ext-all.css" />
        <link rel="stylesheet" type="text/css" href="../shared/example.css" />
        <script type="text/javascript" src="../../bootstrap.js"></script>
          <script type="text/javascript" src="../ux/exporter/swfobject.js"></script>
          
          <script type="text/javascript" src="../ux/exporter/downloadify.min.js"></script>
           <script type="text/javascript" src="../ux/exporter/Button.js"></script>
        <!-- page specific -->
        <style type="text/css">
            /* style rows on mouseover */
            .x-grid-row-over .x-grid-cell-inner {
                font-weight: bold;
            }
            /* shared styles for the ActionColumn icons */
            .x-action-col-cell img {
                height: 16px;
                width: 16px;
                cursor: pointer;
            }
            /* custom icon for the "buy" ActionColumn icon */
            .x-action-col-cell img.buy-col {
                background-image: url(../shared/icons/fam/accept.png);
            }
            /* custom icon for the "alert" ActionColumn icon */
            .x-action-col-cell img.alert-col {
                background-image: url(../shared/icons/fam/error.png);
            }
            .x-ie6 .x-action-col-cell img.buy-col {
                background-image: url(../shared/icons/fam/accept.gif);
            }
            .x-ie6.x-action-col-cell img.alert-col {
                background-image: url(../shared/icons/fam/error.gif);
            }
            .x-ie6 .x-action-col-cell img {
                position:relative;
                top:-1px;
            }
        </style>
        <script type="text/javascript" src="array-grid.js"></script>
    </head>
    <body>
        <h1>Stateful Array Grid Example</h1>
        <p>This example shows how to create a grid from Array data.</p>
        <p>The grid is stateful so you can move or hide columns, reload the page, and come
        back to the grid in the same state you left it in.</p>
        <p>Note that the js is not minified so it is readable. See <a href="array-grid.js">array-grid.js</a>.</p>
        <div id="grid-example"></div>
    </body>
    </html>
    here is my js code
    Code:
    /*
    This file is part of Ext JS 4
    Copyright (c) 2011 Sencha Inc
    Contact:  http://www.sencha.com/contact
    Commercial Usage
    Licensees holding valid commercial licenses may use this file in accordance with the Commercial Software License Agreement provided with the Software or, alternatively, in accordance with the terms contained in a written agreement between you and Sencha.
    If you are unsure which license is appropriate for your use, please contact the sales department at http://www.sencha.com/contact.
    */
    Ext.Loader.setConfig({ enabled: true });
    Ext.Loader.setPath('Ext.ux.exporter','../ux/exporter');
    Ext.require([
        'Ext.grid.*',
        'Ext.data.*',
        'Ext.util.*',
        'Ext.form.*',
        'Ext.state.*',
        'Ext.ux.exporter.Exporter.*',
    'Ext.ux.exporter.excelFormatter.*',
    'Ext.ux.exporter.csvFormatter.*',
    'Ext.ux.exporter.Button.*'
    ]);
    Ext.onReady(function () {
        Ext.QuickTips.init();
        // setup the state provider, all state information will be saved to a cookie
        Ext.state.Manager.setProvider(Ext.create('Ext.state.CookieProvider'));
        // sample static data for the store
        var myData = [
            ['3m Co', 71.72, 0.02, 0.03, '9/1 12:00am'],
            ['Alcoa Inc', 29.01, 0.42, 1.47, '9/1 12:00am'],
            ['Altria Group Inc', 83.81, 0.28, 0.34, '9/1 12:00am'],
            ['American Express Company', 52.55, 0.01, 0.02, '9/1 12:00am'],
            ['American International Group, Inc.', 64.13, 0.31, 0.49, '9/1 12:00am'],
            ['AT&T Inc.', 31.61, -0.48, -1.54, '9/1 12:00am'],
            ['Boeing Co.', 75.43, 0.53, 0.71, '9/1 12:00am'],
            ['Caterpillar Inc.', 67.27, 0.92, 1.39, '9/1 12:00am'],
            ['Citigroup, Inc.', 49.37, 0.02, 0.04, '9/1 12:00am'],
            ['E.I. du Pont de Nemours and Company', 40.48, 0.51, 1.28, '9/1 12:00am'],
            ['Exxon Mobil Corp', 68.1, -0.43, -0.64, '9/1 12:00am'],
            ['General Electric Company', 34.14, -0.08, -0.23, '9/1 12:00am'],
            ['General Motors Corporation', 30.27, 1.09, 3.74, '9/1 12:00am'],
            ['Hewlett-Packard Co.', 36.53, -0.03, -0.08, '9/1 12:00am'],
            ['Honeywell Intl Inc', 38.77, 0.05, 0.13, '9/1 12:00am'],
            ['Intel Corporation', 19.88, 0.31, 1.58, '9/1 12:00am'],
            ['International Business Machines', 81.41, 0.44, 0.54, '9/1 12:00am'],
            ['Johnson & Johnson', 64.72, 0.06, 0.09, '9/1 12:00am'],
            ['JP Morgan & Chase & Co', 45.73, 0.07, 0.15, '9/1 12:00am'],
            ['McDonald\'s Corporation', 36.76, 0.86, 2.40, '9/1 12:00am'],
            ['Merck & Co., Inc.', 40.96, 0.41, 1.01, '9/1 12:00am'],
            ['Microsoft Corporation', 25.84, 0.14, 0.54, '9/1 12:00am'],
            ['Pfizer Inc', 27.96, 0.4, 1.45, '9/1 12:00am'],
            ['The Coca-Cola Company', 45.07, 0.26, 0.58, '9/1 12:00am'],
            ['The Home Depot, Inc.', 34.64, 0.35, 1.02, '9/1 12:00am'],
            ['The Procter & Gamble Company', 61.91, 0.01, 0.02, '9/1 12:00am'],
            ['United Technologies Corporation', 63.26, 0.55, 0.88, '9/1 12:00am'],
            ['Verizon Communications', 35.57, 0.39, 1.11, '9/1 12:00am'],
            ['Wal-Mart Stores, Inc.', 45.45, 0.73, 1.63, '9/1 12:00am']
        ];
        /**
        * Custom function used for column renderer
        * @param {Object} val
        */
        function change(val) {
            if (val > 0) {
                return '<span style="color:green;">' + val + '</span>';
            } else if (val < 0) {
                return '<span style="color:red;">' + val + '</span>';
            }
            return val;
        }
        /**
        * Custom function used for column renderer
        * @param {Object} val
        */
        function pctChange(val) {
            if (val > 0) {
                return '<span style="color:green;">' + val + '%</span>';
            } else if (val < 0) {
                return '<span style="color:red;">' + val + '%</span>';
            }
            return val;
        }
        // create the data store
        var store = Ext.create('Ext.data.ArrayStore', {
            fields: [
               { name: 'company' },
               { name: 'price', type: 'float' },
               { name: 'change', type: 'float' },
               { name: 'pctChange', type: 'float' },
               { name: 'lastChange', type: 'date', dateFormat: 'n/j h:ia' }
            ],
            data: myData
        });
    //    var exportButton = Ext.create('Ext.ux.exporter.Button', {
    //        component: Ext.getCmp('grid'),
    //        icon: '../ux/exporter/download.png',
    //        text: "export Excel"
    //    });
    
        // create the Grid
        var gridPanel = Ext.create('Ext.grid.Panel', {
            store: store,
            stateful: true,
            stateId: 'stateGrid',
            columns: [
                {
                    text: 'Company',
                    flex: 1,
                    sortable: false,
                    dataIndex: 'company'
                },
                {
                    text: 'Price',
                    width: 75,
                    sortable: true,
                    renderer: 'usMoney',
                    dataIndex: 'price'
                },
                {
                    text: 'Change',
                    width: 75,
                    sortable: true,
                    renderer: change,
                    dataIndex: 'change'
                },
                {
                    text: '% Change',
                    width: 75,
                    sortable: true,
                    renderer: pctChange,
                    dataIndex: 'pctChange'
                },
                {
                    text: 'Last Updated',
                    width: 85,
                    sortable: true,
                    renderer: Ext.util.Format.dateRenderer('m/d/Y'),
                    dataIndex: 'lastChange'
                },
                {
                    xtype: 'actioncolumn',
                    width: 50,
                    items: [{
                        icon: '../shared/icons/fam/delete.gif',  // Use a URL in the icon config
                        tooltip: 'Sell stock',
                        handler: function (grid, rowIndex, colIndex) {
                            var rec = store.getAt(rowIndex);
                            alert("Sell " + rec.get('company'));
                        }
                    }, {
                        getClass: function (v, meta, rec) {          // Or return a class from a function
                            if (rec.get('change') < 0) {
                                this.items[1].tooltip = 'Hold stock';
                                return 'alert-col';
                            } else {
                                this.items[1].tooltip = 'Buy stock';
                                return 'buy-col';
                            }
                        },
                        handler: function (grid, rowIndex, colIndex) {
                            var rec = store.getAt(rowIndex);
                            alert((rec.get('change') < 0 ? "Hold " : "Buy ") + rec.get('company'));
                        }
                    }]
                }
            ],
    //        dockedItems: [{
    //            xtype: 'toolbar',
    //           cls: 'absolute-form-toolbar',
    //           items: [exportButton]
    //        }]
    //,
            height: 350,
            width: 600,
            title: 'Array Grid',
           
            viewConfig: {
                stripeRows: true
            }
        });
    var exportButton = new Ext.ux.exporter.Button({
        component: gridPanel,
        text: "Download as .xls"
    });
    var gridForm = Ext.create('Ext.form.Panel', {
        id: 'gridForm',
        title: 'Cotizaciones',
        frame: true,
        renderTo: 'grid-example',
        bodyPadding: 5,
        width: 870,
        height: 720,
        fieldDefaults: { labelAlign: 'left', msgTarget: 'side' },
        layout: { type: 'vbox', align: 'stretch' },
        items: [ {
            layout: { type: 'hbox', align: 'stretch' },
            flex: 3,
            border: false,
            bodyStyle: 'background-color: transparent',
            items: [gridPanel]
        }],
        dockedItems: [{
            xtype: 'toolbar',
            cls: 'absolute-form-toolbar',
            items: [exportButton]
        }]
    });
    });
    I have attached the exporter code also.

    I really need to get this working soon.

    thanks
    Attached Files

  10. #60
    Sencha User
    Join Date
    Jun 2008
    Posts
    157
    Vote Rating
    0
    wiznia is on a distinguished road

      0  

    Default


    Download the latest code, it should be fixed now.

Thread Participants: 111

  1. dawesi (1 Post)
  2. feiji1983 (1 Post)
  3. isaac (1 Post)
  4. radtad (4 Posts)
  5. pavanextjs (5 Posts)
  6. aragm (1 Post)
  7. terjeio (1 Post)
  8. il Sergio (2 Posts)
  9. edspencer (1 Post)
  10. nitingautam (2 Posts)
  11. edykstra (3 Posts)
  12. kalchas (4 Posts)
  13. pardha (1 Post)
  14. shelly (1 Post)
  15. talha06 (3 Posts)
  16. vaucer (1 Post)
  17. SMMJ_Dev (7 Posts)
  18. Ekambos (1 Post)
  19. vispiron (1 Post)
  20. sdruckerfig (4 Posts)
  21. jwcraig (1 Post)
  22. dbrin (1 Post)
  23. scaddenp (2 Posts)
  24. grisevich (1 Post)
  25. semialcruz (3 Posts)
  26. krishnarn1 (1 Post)
  27. mikih (1 Post)
  28. Teemac (3 Posts)
  29. jpcoppol (1 Post)
  30. ssuarez (4 Posts)
  31. trinitrotoluen (1 Post)
  32. aladdina (1 Post)
  33. Mental (3 Posts)
  34. nuskin (5 Posts)
  35. droessner (5 Posts)
  36. HIG (1 Post)
  37. jjerome (4 Posts)
  38. bee (2 Posts)
  39. RAD001 (8 Posts)
  40. RNL (1 Post)
  41. shawon (4 Posts)
  42. parkcity (4 Posts)
  43. carlosgoias (1 Post)
  44. Ewoq (7 Posts)
  45. skotamreddy (1 Post)
  46. another_i (5 Posts)
  47. neerajbherwal (1 Post)
  48. nimda13 (2 Posts)
  49. acteon (2 Posts)
  50. ma1986 (2 Posts)
  51. pierrocknroll (1 Post)
  52. Aranair (7 Posts)
  53. clarkbanks (1 Post)
  54. linyajun (1 Post)
  55. delusion (2 Posts)
  56. Jay Tanwar (2 Posts)
  57. supermarcos (6 Posts)
  58. mmuzamil (1 Post)
  59. amishra06 (1 Post)
  60. hundare (1 Post)
  61. Ecthelion (1 Post)
  62. balajivaikar (2 Posts)
  63. jarobi (1 Post)
  64. ferchotipin (2 Posts)
  65. sebas2515 (3 Posts)
  66. arpeggian (3 Posts)
  67. a_kanin (1 Post)
  68. MeDigital (1 Post)
  69. Vasanthoo7 (3 Posts)
  70. jeora (1 Post)
  71. BlackLine (1 Post)
  72. mrhomer (7 Posts)
  73. KostasP (2 Posts)
  74. rdominelli (4 Posts)
  75. pksiv (1 Post)
  76. yoisen (2 Posts)
  77. opms (1 Post)
  78. Oxii (1 Post)
  79. sarz (6 Posts)
  80. gabsoftware (3 Posts)
  81. 9josh (1 Post)
  82. ananthk (2 Posts)
  83. psnprasad (1 Post)
  84. alex9311 (2 Posts)
  85. felix822 (2 Posts)
  86. mpasacrita@escholar.com (1 Post)
  87. Garry Hawkins (1 Post)
  88. chandrima31 (1 Post)
  89. this-is-sparta (1 Post)
  90. vitalz (7 Posts)
  91. Sheng_Yunzhou (2 Posts)
  92. xdengli (1 Post)
  93. sgscontact (1 Post)
  94. nitingogia@gmail.com (1 Post)
  95. Swetosuvro (1 Post)
  96. sudrak (1 Post)
  97. cdmein (1 Post)
  98. code4jhon (1 Post)
  99. felixfang (2 Posts)
  100. jayasingh1802 (2 Posts)
  101. abdul haq (3 Posts)
  102. gilmaredo@gmail.com (1 Post)
  103. ricardo.lourival (1 Post)
  104. Sundarganesh Ramar (1 Post)
  105. madhavan281981 (1 Post)
  106. suvo (3 Posts)
  107. shankar8rajah1 (1 Post)
  108. benny_GI (1 Post)
  109. cojocarutudor (1 Post)
  110. arnoldvillasanta (4 Posts)
  111. tajashwin (1 Post)