To get the orderId of the proper order is?

2 posts, 1 answers
  1. Ikou
    Ikou avatar
    12 posts
    Member since:
    Aug 2015

    Posted 21 Jan Link to this post

    Hi. 
    Task is I want to get the orderId the appropriate value is entered when it is added.
    rather than the appropriate value be acquired orderId at the timing of the add, 0 Contains.
    Is there get the appropriate value has entered orderId at the timing of the add?

     

    $("#gantt").kendoGantt({
      dataSource: [
        {
          id: 1,
          orderId: 0,
          parentId: null,
          title: "Task1",
          start: new Date("2014/6/17 9:00"),
          end: new Date("2014/6/17 11:00")
        }
      ],
      add: function(e) {
        console.log(e.task.orderId); // If you want to output a 1 is output is zero
      }
    });

     

    Thanks.

  2. Answer
    Dimitar Terziev
    Admin
    Dimitar Terziev avatar
    1266 posts

    Posted 22 Jan Link to this post

    Hello,

    The 'add' event is fired before the newly created gantt task is added to the dataSource and since the orderId is calculated after the task is added to the dataSource, thus its value is always "0", which is the default value. In order to obtain the orderId of the newly added tasks, the following code snippet could be used:
    var newTaskUid;
     
           $("#gantt").kendoGantt({
               dataSource: [
                   {
                       id: 1,
                       orderId: 0,
                       parentId: null,
                       title: "Task1",
                       start: new Date("2014/6/17 9:00"),
                       end: new Date("2014/6/17 11:00")
                   }
               ],
               add: function(e) {
                   newTaskUid = e.task.uid;
               },
               dataBound: function(e) {
                   var newTask = this.dataSource.getByUid(newTaskUid);
     
                   if (newTask) {
                       console.log(newTask.orderId);
                   }
               }
           });


    Regards,
    Dimitar Terziev
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  3. Kendo UI is VS 2017 Ready
Back to Top