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

telerik RadGantt Binding from Code behind

14 Answers 479 Views
Gantt
This is a migrated thread and some comments may be shown as answers.
jahangeer
Top achievements
Rank 1
jahangeer asked on 16 Sep 2014, 02:43 PM
I want to bind Rad Gantt of Telerik from code behind here is my code:
<telerik:RadGantt runat="server" ID="RadGantt1" Width="1275px" Height="600px" ListWidth="351px"
SelectedView="WeekView" Skin="Silk" AutoGenerateColumns="false">
<Columns>
<telerik:GanttBoundColumn DataField="TaskName" DataType="String" Width="120px"></telerik:GanttBoundColumn>
<telerik:GanttBoundColumn DataField="StartDate" DataType="DateTime" DataFormatString="dd/MM/yy" Width="40px"></telerik:GanttBoundColumn>
<telerik:GanttBoundColumn DataField="EndDate" DataType="DateTime" DataFormatString="dd/MM/yy" Width="40px"></telerik:GanttBoundColumn>
</Columns>
<DataBindings>
<TasksDataBindings IdField="TaskID" ParentIdField="TaskID" StartField="StartDate" OrderIdField="TaskID" SummaryField="Summary" ExpandedField="Expanded" EndField="EndDate" TitleField="TaskName"
PercentCompleteField="PercentComplete" />
<DependenciesDataBindings TypeField="Type" IdField="TaskID" PredecessorIdField="TaskID" SuccessorIdField="TaskID" />
</DataBindings>
</telerik:RadGantt>
and in code behindRadGantt1.DataSource = Gatdata();
RadGantt1.DataBind();I am having this error on DataBind() "DataSourceID may not be null in case of DataSource binding" here GetData() method return very simple datatable which contains columns and valid data

14 Answers, 1 is accepted

Sort by
0
Bozhidar
Telerik team
answered on 17 Sep 2014, 05:35 AM
Hi,

This functionality was not available in the Beta release of the control. You can however download the latest internal build and it should work.

Regards,
Bozhidar
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Felix
Top achievements
Rank 1
answered on 19 Sep 2014, 01:04 PM
Hi,

I just downloaded the latest internal build (Telerik_UI_for_ASP.NET_AJAX_2014_2_916_Dev_hotfix) and got several problems with my XMLGanttProvider that I've used so far, if I want to insert, update or delete tasks. Did you change the xml-structure? But thats another topic.
So I've tried to bind the RadGantt from code behind, which works perfectly. But if i try to e.g. update a task inside "OnTaskUpdate" - event, I get the same error: "DataSourceID may not be null in case of DataSource binding". What is the benefit of binding the RadGantt from Code behind when I get the same Error as before if I want to update my tasks...

Regards,
Felix
0
Bozhidar
Telerik team
answered on 19 Sep 2014, 02:17 PM
Hi Felix,

I've attached a fully runnable example of a Gantt bound using the DataSource property from code behind, and with all the CRUD operations implemented through the Server events. Could you confirm if the sample is working on your end?

As for the XML provider issues, could you open a support ticket and share a sample project, so that we can investigate the issues in detail?

Regards,
Bozhidar
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Felix
Top achievements
Rank 1
answered on 22 Sep 2014, 09:19 AM
Hi Bozhidar,

I looked at your sample project and found the problem. I didn't know that I have to set the Datasoure-property on every postback. Since I have set it on every postback, everything looks fine. Thank you.

Regards,
Felix
0
Sam
Top achievements
Rank 1
answered on 29 Oct 2014, 01:01 PM
Bozhidar, I am having an issue with the RadGantt. When I attach a OnTaskDelete event, the confirmation for the delete appears and the form is automatically submitted. Is this a bug in the control? It doesn't happen when I declare the datasource. This only happens when I try and bind the control in the code behind. 
0
Bozhidar
Telerik team
answered on 30 Oct 2014, 07:47 AM
Hello,

I confirm that this is a bug, which we've already addressed and will be fixed in the next internal build. In the meantime to prevent the erroneous behavior you can just set DisplayDeleteConfirmation="false" to prevent the dialog from opening.

Regards,
Bozhidar
Telerik
0
Sam
Top achievements
Rank 1
answered on 30 Oct 2014, 10:49 AM
Ok, not a problem. Will do that. So that means I should probably have a separate save button in order to do one save. Kind of unrelated, but is there an easy way to add a button to the toolbar? Currently I'm using jquery to do so but was just curious if there was a way to add it without doing it client side. 
0
Sam
Top achievements
Rank 1
answered on 30 Oct 2014, 01:51 PM
One other question if you don't mind, when I add a task none of the form variables retain their value nor is the viewstate is available. Is this by design? What if you need to pass additional data set on the form to the insert event?

0
Sam
Top achievements
Rank 1
answered on 30 Oct 2014, 06:02 PM
Bozhidar, I decided to stay with the declarative binding of the gantt. However, there is another issue with the gantt chart. If you have a parameter in the select statement or even a hard-coded WHERE clause, the gantt never comes back after an add. I get the JS error Uncaught TypeError: Cannot read property 'Start' of null. The record is added to the database but the gantt just sits there in wait mode. 
0
Bozhidar
Telerik team
answered on 31 Oct 2014, 07:31 AM
Hi ,

When you insert a task into the database, the Gantt expects the same task to be immediately returned by the datasource, so that it can have the new ID, that the datasource has assigned to it. Perhaps your WHERE clause excludes the newly entered task and it can't be found after the insert statement, which causes the gantt to hang.

Unfortunately this is hard to troubleshoot without some kind of sample to work on and debug. Would it be possible for you to send us a simplified sample that demonstrates the issue.

Regards,
Bozhidar
Telerik
0
Sam
Top achievements
Rank 1
answered on 31 Oct 2014, 12:00 PM
Oh I see. Yes, the filter was preventing the record from coming back. The issue is that I am populating a field on the form. That field is used in the code behind to filter the results for the gantt. However, the field is blank when a new task is added. I'm assuming the gantt uses it's own ajax and does not go through the ajaxmanager. I tried adding the field as an attribute to the gantt but that value didn't hold up on the gantt postback either. Is there a way to pass values back to the server from a gantt postback? 
0
Bozhidar
Telerik team
answered on 03 Nov 2014, 07:27 AM
Hello,

With the recently released official version of the Gantt control (Q3 2014), when you use server events a full postback is triggered, which will transfer all the ViewState of all controls on the page. If you don't have an event attached, a simple callback is performed on each operation, which doesn't update the other controls on the page. So in your case you just have to handle the server OnTaskInsert event (and any other event for operations where you wish to trigger a full postback).

Regards,
Bozhidar
Telerik
0
Jahangeer
Top achievements
Rank 1
answered on 24 Jun 2015, 05:37 AM
I have implemented your entire code but same error of "DataSourceID may not be null in case of DataSource binding" what to do now??
0
Bozhidar
Telerik team
answered on 24 Jun 2015, 06:46 AM
Hi,

What is your version of the controls? If you run the attached page from a few answers back with the latest version of the controls, it should be working.

Regards,
Bozhidar
Telerik
Tags
Gantt
Asked by
jahangeer
Top achievements
Rank 1
Answers by
Bozhidar
Telerik team
Felix
Top achievements
Rank 1
Sam
Top achievements
Rank 1
Jahangeer
Top achievements
Rank 1
Share this question
or