1

I have mail.txt on my local machine and i want to display it on the UI using extjs. I created a textarea and want to import mail.txt into it.

Ext.define('com.company.view.dashboard.Dashboard', {
extend: 'Ext.panel.Panel',
alias: 'widget.dashboard',
layout: 'fit',
iconCls: 'dashboard-tree',      
initComponent: function(config) {
    Ext.apply(this, {
        items: [
            {
            xtype: 'fieldcontainer',
            fieldLabel: 'P&L',
            labelWidth: 100,
            layout: 'hbox',
            items: [{
                xtype: 'textarea',
                flex: 1
            }]
            }
        ]
    });
    this.callParent(arguments);
}});
  • 1
    Possible duplicate of [Read a local text file using Javascript](http://stackoverflow.com/questions/27522979/read-a-local-text-file-using-javascript) – Quentin Mar 23 '17 at 08:41
  • 2
    Welcome to SOF. Post you code in question what you have tried. Also make clear what exactly you want and where you get stuck. – UDID Mar 23 '17 at 08:58

1 Answers1

2

Here If you want to Display text file in UI then what I will suggest you is put you text content in to JSON format and then on top of window or Panel you can display that.

In This example I am displaying on window. You can make as per your requirment.

Here is MyMessage function which can take the response and then display on MyMessageWindow .

MyMessage : function(){
        var me = this;
        Ext.Ajax.request({
            url : URL of your JSON
            method : 'GET',
            dataType:'json',
            scope : me,
            headers : {
                "Accept" : "application/json; charset=utf-8"
            },
            success : function (response, args) {
                var data = Ext.decode(response.responseText);
                var Msgtext = data.R.MSG;  // This is depend on how you binding data in JSON.
                me.MyMessageWindow(Msgtext);
            }
        });
    },
    MyMessageWindow : function(Msgtext){
        var FailedMsgShow = function (text) {
                Ext.create({
                    xtype: 'window',
                    title: 'P&L',
                    width: 600,
                    height: 450,
                    html:text,
                    scrollable: true,

                }).show();
            };
        FailedMsgShow('<text style="color:green;">'+Msgtext+'</text>');
    },

Note : You can display on any component like panel. I just suggesting you to put on window. you can make on panel as well instead of fieldContainer.

UDID
  • 2,350
  • 3
  • 16
  • 31