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

Save and Databind events being called multiple times

3 Answers 765 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Siddhartha
Top achievements
Rank 1
Siddhartha asked on 17 Feb 2017, 08:44 AM

Hi,
In my scheduler i am performing database  update while i click on save button on event popup.

The save gets called 2 to 3 times calling the same database SP. This though handled in the SP causes a performance issue as the Scheduler takes time to refresh.

This is happening on some machines and is not happening on some at all.

I also noticed that the Databind event gets called multiple times. Any idea how this can be avoided. Anyone ever experience the same set of issues.

Thanks
Siddhartha

3 Answers, 1 is accepted

Sort by
0
Ianko
Telerik team
answered on 21 Feb 2017, 08:19 AM

Hello Siddhartha,

From the described scenario I am not exactly sure which is the event handled during the save to database is performed. 

Can you demonstrate the situation on your end by updating this dojo here: http://dojo.telerik.com/OmELe

On a side note, if you are binding data using the DataSource, it is suggested to use the DataSource events. For example, the sync event might be suitable for the case.

Regards,
Ianko
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
Siddhartha
Top achievements
Rank 1
answered on 22 Feb 2017, 07:32 AM

Hi Ianko,

I would not be able to replicate the issue in the dojo. We use a tool called Skelta forms a product by Schneider. In this we have an option to incorporate JavaScript which gets rendered on the page.

Below are code snippets that are written into the form which gets executed on a button click.

var scheduler = $("#schedulerS1").data("kendoScheduler");
scheduler.bind("save", scheduler_save);
scheduler.bind("edit", scheduler_edit);
scheduler.bind("dataBound", scheduler_dataBound);
scheduler.bind("resizeEnd", scheduler_resize);
var options = scheduler.options;
options.startTime = new Date(date);
options.majorTick= SchedMajorTick;
//options.minorTickCount = SchedMinorTick;
options.columnWidth = SchedMinorTick;
build_scheduler(scheduler);

 

The build Scheduler function calls ----------

$.ajaxSetup({ cache: true});
$.ajax( {
  url: "http://"+host+"/MDMToolkit//api/MESLookup?ObjectName=MDM_Sched_Get_ScheduledJob&Command=GetByKey&filterParams="+
  JSON.stringify(ParamsArray),
  contentType: "application/jsonp; charset=utf-8",
  async:false,
  dataType: "json",
  success: function (records)
  {
    POdata = records;
  },
  error: function (err)
  {
    console.log('err:'+err.responseText);
  }
});
for(var k=0;k<POdata.length;k++)
{
  if(POdata[k].is_downtime_exists == 1)
  {
    jobTitle = "* "+POdata[k].job_priority+ " : "+POdata[k].wo_id + " : "+POdata[k].item_id +" : "+POdata[k].req_qty;
  }
  else
  {
    jobTitle = POdata[k].job_priority+ " : "+POdata[k].wo_id + " : "+POdata[k].item_id +" : "+POdata[k].req_qty;
  }
  listPO.push({id:POdata[k].row_id, start: POdata[k].job_latest_start_time, end: POdata[k].job_req_finished_time ,
               job_id: POdata[k].oper_id, wo_id:POdata[k].wo_id,mo_id:POdata[k].mo_id,title:jobTitle, item_id:POdata[k].item_id,oper_id:POdata[k].oper_id,
               ent_name:POdata[k].job_sched_entity_name,priority:POdata[k].job_priority ,req_qty:POdata[k].req_qty,req_qty_original:POdata[k].req_qty,job_seq_no:POdata[k].job_seq_no,
               job_sched_entity_id:POdata[k].job_sched_entity_id,splited_qty:0,new_job_entName:0,is_downtime_exists:POdata[k].is_downtime_exists,
               job_state:POdata[k].job_state,wo_state:POdata[k].wo_state});
}
var dataSource = new kendo.data.SchedulerDataSource({
  sync: dataSource_sync(),
  data: listPO
});
scheduler.setDataSource(dataSource);
if(initialJVLoad === true)//add code scheduler destroy for resources.
{
  initialJVLoad = false;
  for(  count = 0 ;count < POdata.length ;count++)
  {
    if(arrWO.indexOf(POdata[count].oper_id) == -1)
    {
      arrWO.push(POdata[count].oper_id);
      scheduler.resources[0].dataSource.add({text: POdata[count].oper_id, value: POdata[count].oper_id ,color: "#6eb3fa" });
    }
  }
}

 scheduler.view(scheduler.view().name);
  scheduler.date(new Date(date));

 

The function Scheduler Save calls the Build Scheduler post making database updates.

 

function scheduler_save(e) {

//database functions

build_scheduler(scheduler);

 

}

 

Attached is the file with the complete code.

 

Thanks

Siddhartha

 

 

0
Ianko
Telerik team
answered on 23 Feb 2017, 03:32 PM

Hello Siddhartha,

With the code sent I am unable to exactly define why events would be triggered multiple times. I see that they are handled, but with only this code I am unable to run it and possibly reproduce the described situation. 

I am not sure how the third-party tool could be related to the case here. Therefore, I suggest you isolating a more generic example which demonstrates the described issue so that I can reproduce it locally and examine it properly. 

Regards,
Ianko
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
Scheduler
Asked by
Siddhartha
Top achievements
Rank 1
Answers by
Ianko
Telerik team
Siddhartha
Top achievements
Rank 1
Share this question
or