Manipulate Task DataSource

6 posts, 3 answers
  1. Nabil
    Nabil avatar
    29 posts
    Member since:
    Dec 2017

    Posted 04 Jan Link to this post

    Hello Telerik Team !

    I'm using telerik gantt chart for MVC

    i want to ask can i manipulate tasks data before it get's bind to the chart ?

    like when READ action for task data source gets fired and get the data from server and then at client side before binding tasks to chart it can be changed.

     

    can i do that ? kindly tell.

     

    Thank You.

  2. Answer
    Veselin Tsvetanov
    Admin
    Veselin Tsvetanov avatar
    744 posts

    Posted 08 Jan Link to this post

    Hi Nabil,

    Yes you can manipulate the data recived from the remote by specifying a schema.parse function for the Gantt DataSource. Note, that in order to be able to configure the Parse() function, you will have to use a Custom DataSource for the Gantt HTML helper:
    .DataSource(d => d
        .Custom()
        .Schema(s => s
            .Model(m =>
            {
                m.Id(f => f.TaskID);
                m.Field("title", typeof(string)).From("Title");
                m.Field("start", typeof(DateTime)).From("Start");
                m.Field("end", typeof(DateTime)).From("End");
                m.Field("parentId", typeof(int)).From("ParentID");
                m.Field("OrderId", typeof(int)).From("OrderId");
                m.Field("expanded", typeof(int)).From("Expanded").DefaultValue(true);
            })
            .Parse(@<text>function (data) {
                // configure a parse function only if the response (data) must be
                // transformed in some way before data binding
                return data;
            }</text>)
            .Data("Data")
        )
        .Transport(t => t
            .Read("ReadTasks", "Task")
            .Create("CreateTask", "Task")
            .Destroy("DestroyTask", "Task")
            .Update("UpdateTask", "Task")
        )
    )

    Note, that all fields should be properly described in the Model section. Further information on that topic could be found in our Documentation.

    Regards,
    Veselin Tsvetanov
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  3. Nabil
    Nabil avatar
    29 posts
    Member since:
    Dec 2017

    Posted 09 Jan in reply to Veselin Tsvetanov Link to this post

    can same thing happen in Resources ? i mean before opening the resources dialog box i can make change in datasource then let it append in dialogbox?

  4. Answer
    Veselin Tsvetanov
    Admin
    Veselin Tsvetanov avatar
    744 posts

    Posted 11 Jan Link to this post

    Hello Nabil,

    Yes, the same could be applied to for the Gantt Resources datasource too:
    .Resources(r => r
        .Field("resources")
        .DataColorField("Color")
        .DataTextField("Name")
        .DataSource(d => d
            .Custom()
            .Schema(s => s
                .Model(m => m.Id("ID"))
                .Data("Data")
                .Parse(@<text>function (data) {
                    // configure a parse function only if the response (data) must be
                    // transformed in some way before data binding
                    return data;
                }</text>)
            )
            .Transport(t =>
            {
                t.Read("ReadResources", "Gantt");
            })
        )
    )

    Regards,
    Veselin Tsvetanov
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  5. Nabil
    Nabil avatar
    29 posts
    Member since:
    Dec 2017

    Posted 12 Jan in reply to Veselin Tsvetanov Link to this post

    hey . i was trying to get the assignments for the particular task in OnEdit event and in OnSave event. i was able to get only the resources but not the assignments for that task ?

    i mean if i have one assigned resource coming from database and that is checked in resources dialog box. if I check one more resource and hit have button of task dialog box in OnSave event i'm getting the resource only which was coming from database. not the new one which i checked and hit save button. how can i get the new assigned resources ? i have not seen any Assignment property in my selected task as well.

  6. Answer
    Veselin Tsvetanov
    Admin
    Veselin Tsvetanov avatar
    744 posts

    Posted 15 Jan Link to this post

    Hello Nabil,

    The newly added assignments will be present in the values field of the evenArgs object of the save event handler of the widget:
    function onSave(e) {
      var values = e.values;
      var addedResources = values.resources;
      console.log(addedResources);
    };

    Regards,
    Veselin Tsvetanov
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top