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

Manipulate Task DataSource

5 Answers 85 Views
Gantt
This is a migrated thread and some comments may be shown as answers.
Nabil
Top achievements
Rank 1
Nabil asked on 04 Jan 2018, 01:56 PM

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.

5 Answers, 1 is accepted

Sort by
0
Accepted
Veselin Tsvetanov
Telerik team
answered on 08 Jan 2018, 10:43 AM
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.
0
Nabil
Top achievements
Rank 1
answered on 09 Jan 2018, 11:25 AM

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?

0
Accepted
Veselin Tsvetanov
Telerik team
answered on 11 Jan 2018, 09:49 AM
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.
0
Nabil
Top achievements
Rank 1
answered on 12 Jan 2018, 06:11 AM

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.

0
Accepted
Veselin Tsvetanov
Telerik team
answered on 15 Jan 2018, 02:57 PM
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.
Tags
Gantt
Asked by
Nabil
Top achievements
Rank 1
Answers by
Veselin Tsvetanov
Telerik team
Nabil
Top achievements
Rank 1
Share this question
or