Jump to content

to match js code grid to unigui

Recommended Posts

how can I use this js code in unigui?

Ext.onReady(function () {
    var grid = Ext.widget({
        xtype: 'grid',
        height: 400,
        store: {
            fields: ['name', 'size', 'progress', 'status']
        tbar: [{
            xtype: 'filefield',
            buttonOnly: true,
            width: 10,
            listeners: {
                render: function (s) {
                    s.fileInputEl.set({ multiple: 'multiple' });
                change: function (s) {
                    Ext.each(s.fileInputEl.dom.files, function (f) {
                        var data = new FormData(),
                            rec = grid.store.add({ name: f.name, size: f.size, status: 'queued' })[0];
                        data.append('file', f);
                            url: '/upload/files',
                            rawData: data,
                            headers: { 'Content-Type': null }, //to use content type of FormData
                            progress: function (e) {
                                rec.set('progress', e.loaded / e.total);
                                rec.set('status', 'uploading...');
                            success: function () {
                                rec.set('status', 'done');
                            failure: function () {
                                rec.set('progress', 0);
                                rec.set('status', 'failed');
        columns: [
            { text: 'Name', dataIndex: 'name', flex: 1 },
            { text: 'Status', dataIndex: 'status', width: 100 },
                text: 'Progress', xtype: 'widgetcolumn', widget: {
                    xtype: 'progressbarwidget',
                    textTpl: [
                }, dataIndex: 'progress', width: 100
            { text: 'Size', dataIndex: 'size', width: 100, renderer: Ext.util.Format.fileSize }
        renderTo: Ext.getBody()

thanks for the help

Link to post
Share on other sites

It is all available in unigui framework, except the progressbar that indicates the ‰ of the upload process, if you want to handle it manually you have also to handle server side code, anyway you may use the event 'viewready' in the clientevents of the grid and then for the specific column add your progress bar, also you may use the column renderer event to insert the progressbar.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...