Show cool things you have done with our products


Post by gopi »

Hi Mats,

I wonder if you can help me in here.
I want to handle errors when a task fails to update the Gantt chart. And also a notification message to display the success/failure message after saving.
I tried adding this in taskstore, but no luck.
 successProperty: 'success',

  listeners: {
                    exception: function () {
                        alert(success);
                    }
                },
here is my code for taskstore
 var taskStore = Ext.create("Gnt.data.TaskStore", {
            model: 'TaskModel',
            calendar        : rootCalendar,  
            proxy: {
                type: 'ajax',
                headers: { "Content-Type": 'application/json' },
                api: {
                    read: 'webservices/tasks.asmx/Get',
                    create: 'webservices/tasks.asmx/Create',
                    destroy: 'webservices/tasks.asmx/Delete',
                    update: 'webservices/tasks.asmx/Update'
                },
                writer: {
                    type: 'json',
                    root: 'jsonData',
                    encode: false,
                    allowSingle: false
                },
                reader: {
                    type: 'json',
                    root: function (o) {
                        if (o.d) {
                            return o.d;
                        }
                        else {
                            return o.children;
                        }
                    }
                }
            }
        });
here is my code for Ext.create("MyApp.DemoGanttPanel"
  var g = Ext.create("MyApp.DemoGanttPanel", {
            region: 'center',
            rowHeight: 26,
            selModel: new Ext.selection.TreeModel({
                ignoreRightMouseSelection: false,
                mode: 'MULTI'
            }),
            taskStore: taskStore,
            dependencyStore: dependencyStore,
            assignmentStore: assignmentStore,
            resourceStore: resourceStore,
//            generalShiftCalendar: generalShiftCalendar,
            generalCalendar: rootCalendar,
    
            //snapToIncrement : true,    // Uncomment this line to get snapping behavior for resizing/dragging.
            columnLines: false, 
            rowLines: false,

            startDate: new Date(2013, 6, 11),
            //  endDate: Sch.util.Date.add(new Date(2013, 6, 4), Sch.util.Date.WEEK, 20),
            endDate: Sch.util.Date.add(new Date(2013, 6, 11), Sch.util.Date.MONTH, 10),

            viewPreset: 'weekAndDayLetter',
            // GK added new properties
            //renderTo: Ext.getBody(),               
            renderTo: 'gantt_container',
            multiSelect: true,
            cascadeChanges: true,
            rightLabelField : 'Responsible',
            
            // GK ends here
        });        

        g.on({
            dependencydblclick: function (ga, rec) {
                var from = taskStore.getNodeById(rec.get('From')).get('Name'),
                to = taskStore.getNodeById(rec.get('To')).get('Name');

                Ext.Msg.alert('Hey', Ext.String.format('You clicked the link between "{0}" and "{1}"', from, to));
            },
            timeheaderdblclick: function (col, start, end) {
                Ext.Msg.alert('Hey', 'You click header cell : ' + Ext.Date.format(start, 'd-m-Y') + ' - ' + Ext.Date.format(end, 'd-m-Y'));
            }
        });

        return g;
    }
please let me know if you want any further information.

Thanks
Gopi

Post by mats »

I don't see any exception event listed in TreeStore. https://docs.sencha.com/extjs/4.1.3/#!/a ... .TreeStore

Look at the 'proxy' class perhaps? :)

Post by gopi »

Hi Mats,
I am not clear with your answer.
I want to handle errors when a task fails to update the Gantt chart. And also a notification message to display the success/failure message after saving. I tried adding this in taskstore, but no luck.

Will you please give me some pseudo code to handle it. Or are there any such examples in the downloaded examples folder? I just made this working with the example given in downloaded asp.net.

Thanks
GK

Post by nickolay »

You need to listen for "exception" event on the store's proxy, not on the store itself:
https://docs.sencha.com/extjs/4.2.0/#!/a ... -exception

Or you can provide callback/errback for "store.sync()" call:
https://docs.sencha.com/extjs/4.2.0/#!/a ... ethod-sync

Post by gopi »

Thanks Nickolay! It's working now.
I have placed my code in taskStore.Sync.
 
gantt.taskStore.sync(
                                {
                                    success: function () {
                                        Ext.Msg.alert('Tasks updated successfully');
                                    },
                                    failure: function () {
                                        Ext.Msg.alert('Tasks not updated, please refresh your browser');
                                    },
                                    scope: this
                                }
                            );
Thanks
GK

Post Reply