Show cool things you have done with our products


Post by mats »

g.getView().refresh()

Post by Chandrashekhar27 »

Hi

Refresh problem...

After adding dependencey by drag and drop need to reload chart.....
App.Scheduler = {

    // Initialize application
    init: function (serverCfg) {
        this.gantt = this.createGantt();

        var vp = new Ext.Viewport({
            layout: 'fit',
            items: this.gantt
        });

        this.initEvents();

    }
 createGantt: function () {
var g = new App.MyGanttPanel({
            // region: 'center',
            startDate: start,
            endDate: end,
            viewPreset: 'weekAndDayLetter',

            taskStore: taskStore,
            dependencyStore: dependencyStore

        });
      g.getView().refresh() //if i used here Exception is "Uncaught TypeError: Cannot call method 'stopEditing' of undefined"
        return g;
    }
where need to call following code??
g.getView().refresh()
if call before "vp" following exception is coming in "Lockinggridview.js"
 refresh : function(headersToo){
        this.fireEvent('beforerefresh', this);
        this.grid.stopEditing(true);
Uncaught TypeError: Cannot call method 'stopEditing' of undefined
        var result = this.renderBody();

Post by jakub »

You need to call the refresh after you add dependency, not when you're creating the panel. Can you show the code which is used for and after adding dependency ?
JavaScript/Angular/ExtJS consulting - kuba@virtualdesign.pl

Post by Chandrashekhar27 »

Hi jakub.
  api: {

                create: 'webservices/Dependencies1.asmx/Create',
                destroy: 'webservices/Dependencies1.asmx/Delete',
                update: 'webservices/Dependencies1.asmx/Update'
            },
            fields : [
               {name:'Id'},
                {name:'From'},
                {name:'To'},
                {name:'Type'}
            ]
        });

        App.DependencyStore.superclass.constructor.call(this, config);
the above code using for adding dependencey.....
where to call "getView().refresh()" ??

Post by jakub »

Can you prepare a working example of your code or just share all of it ? Fragments you've posted are not the ones we need here I believe.
JavaScript/Angular/ExtJS consulting - kuba@virtualdesign.pl

Post by Chandrashekhar27 »

Hi


This is copied from working sample....i need to refresh chart after adding /updating dependency or task
Ext.ns('App');

Ext.onReady(function() {
    Ext.QuickTips.init();
    
    App.Scheduler.init();
});

App.Scheduler = {

    // Initialize application
    init: function (serverCfg) {
        this.gantt = this.createGantt();

        var vp = new Ext.Viewport({
            layout: 'fit',
            items: this.gantt
        });

        this.initEvents();

    },

    initEvents: function () {
        var g = this.gantt;
        // g.getView().refresh();
        g.on({
            'beforeedit': this.beforeEdit,
            'afteredit': this.afterEdit,
            scope: this
        });

        g.store.on('beforewrite', function (s, action, rs) {
            if (action === Ext.data.Api.actions.create) {
                // Fill in some defaults
                Ext.each(rs, function (r) {
                    Ext.applyIf(r.data, {
                        Priority: 'Normal'
                    });
                });
            }
        });

        g.dependencyStore.on('beforewrite', function (s, action, r) {

            if (action === Ext.data.Api.actions.create) {
                // Add a visual clue that the dependency is being processed
                g.getDependencyManager().getElementsForDependency(r).addClass('creating');
                //g.getView().refresh();
            }

        },
        null, { delay: 50 });

    },

    beforeEdit: function (o) {

        // Don't allow editing of parent start dates as those are calculated automatically
        o.cancel = (o.field === 'StartDate') && !o.record.store.isLeafNode(o.record);

    },
    afterEdit: function (o) {

        // Don't allow editing of parent start dates as those are calculated automatically
        //o.cancel = (o.field === 'StartDate') && !o.record.store.isLeafNode(o.record);
        //o.reload();
        //o.getView().refresh()

    },

    createGantt: function () {


        var ProjectReference = getQuerystring('project');
        var start1 = getQuerystring('start') //'01/01/2012'; // Ext.get('ext').dom.value;
        var end1 = getQuerystring('end')// '01/01/2013'//Ext.get('end').dom.value;


        var taskStore = new App.TaskStore(),
            dependencyStore = new App.DependencyStore();
        //taskStore.applyTreeSort();
       // taskStore.getView().refresh();
        var start = new Date(start1);

        var end = new Date(end1);
        end = Sch.util.Date.add(end, Sch.util.Date.WEEK, 20)



        taskStore.save = createBuffered(taskStore.save, 500, taskStore);

        taskStore.on('exception', function () {
            debugger;
            Ext.Msg.alert('Error', 'An error occurred during a task store request');
        });

        dependencyStore.on('exception', function () {
            debugger;
            // Ext.Msg.alert('Error', 'An error occurred during a dependency store request');
        });

        var g = new App.MyGanttPanel({
            // region: 'center',
            startDate: start,
            endDate: end,
            viewPreset: 'weekAndDayLetter',

            taskStore: taskStore,
            dependencyStore: dependencyStore

        });

        return g;
    }
};

function createBuffered(fn, delay, scope){
    fn.task = new Ext.util.DelayedTask();
    return function(){
        fn.task.delay(delay, fn, scope, Array.prototype.slice.call(arguments, 0));
    };
};

Within above code is it possible to call "g.getView().refresh()" ?? to refresh gantt chart

Post by mats »

Yup, or gantt.getSchedulingView().refresh();

Post by Chandrashekhar27 »

App.Scheduler = {

    // Initialize application
    init: function (serverCfg) {
        this.gantt = this.createGantt();
       
        var vp = new Ext.Viewport({
            layout: 'fit',
            items: this.gantt
        });
        this.gantt.getSchedulingView().refresh();//added here chart is not refreshing or reloading
        this.initEvents();

    },

Can u tell where to add exactly.....??

Post by mats »

Why would you want to refresh the view right after it's been rendered? Makes no sense...

Post by Chandrashekhar27 »

Hi Mats

after adding dependency by drag and drop between two task ,i m trying to edit dependency direction, dependency plugin not popping out when i dbclick on arrow,

following error is coming in following link
  loadRecord : function(record){
        this.setValues(record.data);
Uncaught TypeError: Cannot read property 'data' of undefined (repeated 3 times)
        return this;
    },
after reloading the page dependency plugin displying after dbclink on arrow

so i need to refresh after adding dependency or updating the task

and anothher Query
Is it possible to add re-ording tasks within gantt chart[3.4. extjs version]??
please tell me how to refresh or reload gantt chart?? is there any config need to set to add dependency ??

Locked