This is a migrated thread and some comments may be shown as answers.

Update event of the Data Source is getting triggered multiple times for inline edit

5 Answers 397 Views
Gantt
This is a migrated thread and some comments may be shown as answers.
Anagha
Top achievements
Rank 1
Anagha asked on 04 May 2017, 04:06 AM
Hi,
I am using the below code to call the update event of the data source. 
<script>
function error(e) {
            var grid = $("#gantt").data("kendoGantt");
            grid.one("dataBinding", function(args) {
                e.preventDefault();
            });
            if (e.errors) {
                var msg = "";
                $.each(e.errors, function(key, value) {
                    if (value.hasOwnProperty("errors")) {
                        $.each(value.errors, function() {
                            msg += this + "<br />";
                        });
                    }
                });
             alert(msg);
            }
        }
</script>

@(Html.Kendo().Gantt<TaskGantt, TaskGanttDependency>()
    .Name("gantt")
    .DataSource(ds => ds
                        .Read(read => read
                            .Action("Tasks", "Home")
                        )
                        .Update(update => update
                            .Action("Update", "Home")
                        )
                        .Events(events => events
                          .Error("error")
                        )
                        .Model(m =>
                        {
                            m.Id(f => f.Id);
                            m.ParentId(f => f.ParentId);
                            m.OrderId(f => f.OrderId);
                            m.Field(f => f.Expanded).DefaultValue(true);
                        })
                    )
                    .DependenciesDataSource(ds => ds
                        .Read(read => read
                            .Action("Dependencies", "Home")
                        )
                        .Model(m =>
                        {
                            m.Id(f => f.DependencyId);
                            m.PredecessorId(f => f.PredecessorId);
                            m.SuccessorId(f => f.SuccessorId);
                            m.Type(f => f.Type);
                        })
                    )
                    
    .Columns(columns =>
    {
        columns.Bound("title").Editable(true).Sortable(true);
        columns.Bound("end").Title("End Time").Format("{0:MM/dd/yyyy}").Width(100).Editable(true).Sortable(true);  
    })
    .Views(views =>
    {
        views.WeekView(weekView => weekView.Selected(true));
        views.MonthView();
    })
    .Events(events=> events
        .DataBound("onDataBound")
    )
    .Height(500)
    .ShowWorkHours(false)
    .ShowWorkDays(false)
    .Snap(false)
    .Resizable(true)
    )
The update event is getting triggered multiple times when i am trying to update a single task inline. I want the update event to get triggered only once for a single task update.I have also attached the image which indicates the multiple event trigger for the inline edit of the highlighted child task.Can anyone help me in where i am going wrong or what has to be done to prevent the multiple event triggers.

Thanks

5 Answers, 1 is accepted

Sort by
0
Veselin Tsvetanov
Telerik team
answered on 05 May 2017, 09:34 AM
Hi Anagha,

The observed is the expected behaviour of the Gatt chart on update. When editing the start / end date of a Task, which is a child of other tasks, the Update call will be executed for the edited Task and for all its parent tasks. This is needed to adjust the parents start and end to the changes in the duration of the child.

Regards,
Veselin Tsvetanov
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Anagha
Top achievements
Rank 1
answered on 05 May 2017, 09:56 AM

Hi Veselin,

I tried editing the title column and the update gets called multiple times. The child task which has been highlighted in the image in my previous post is the one getting edited and its parent task is Test Project 12, but the update gets called even for the parent task "Test Project 13" and "Test Project 14".

I have observed the same for columns other than the start/end date. Why is that so?

Thanks

0
Veselin Tsvetanov
Telerik team
answered on 09 May 2017, 11:30 AM
Hello Anagha,

Here you will find a small Dojo, implementing the discussed Gantt scenario. You will notice, that multiple calls to the server are observed, when the Start or End date of a child task is being updated, while a single update occurs, when its Title is modified (video here).

May I ask you to modify the above, so it reproduces the issue observed, or prepare and send us an isolated MVC demo project, which shows that problem? This way we will be able to troubleshoot the problem locally and to provide you with the most appropriate assistance for this case.

Regards,
Veselin Tsvetanov
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Anagha
Top achievements
Rank 1
answered on 10 May 2017, 06:09 AM

Hi Veselin,

I found out the issue why the update was getting triggered multiple times. In the image in my first post, the first 2 parent nodes were expanded on data bind and later while editing I collapsed the first 2 parent node and edited the child of the 3rd parent node.So the expanded property of the first 2 parent nodes in the data source got changed from true to false. Since there was a change in the data source of those entries, update event was getting triggered for them also.

But now i do not want the update event to get triggered when we collapse any of the parent node because if there are many tasks and there is an option to collapse and view the chart, the user will collapse and edit a particular task. Then the collapsed node should not be considered for an update event.

So can u help me with how to achieve this, with the existing functionality in Telerik or if there is any workaround for the requirement needed.

Thanks

Anagha 

0
Veselin Tsvetanov
Telerik team
answered on 11 May 2017, 12:57 PM
Hello Anagha,

I am afraid, that the Gantt chart does not offer the possibility to alter its remote binding behaviour for the expanded field. Also, there is no reliable workaround, that would allow you to achieve the desired. 

However, as the discussed may be an issue for other developers too, I would encourage you to log your idea for altering the Gantt behaviour in our Feedback portal. Based on the support it receives from our community, we will decide on whether to proceed with its implementation or not.

Regards,
Veselin Tsvetanov
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Gantt
Asked by
Anagha
Top achievements
Rank 1
Answers by
Veselin Tsvetanov
Telerik team
Anagha
Top achievements
Rank 1
Share this question
or