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

Accessing Page radComboBox from Gantt Custom Provider

4 Answers 45 Views
Gantt
This is a migrated thread and some comments may be shown as answers.
Steve
Top achievements
Rank 1
Veteran
Steve asked on 26 Mar 2021, 12:34 PM

I've implemented the GanttCustomProvider to give me more properties on the task - using a project supplied by a kind persons at Telerik, think it was Peter Milchev .

 

However the GetTasks function in the GanttCustomProvider.vb needs to take into account filters specified by a RadComboBox on the calling page however I don't seem to be able to get to that control.

 

Regards

Steve

4 Answers, 1 is accepted

Sort by
0
Peter Milchev
Telerik team
answered on 31 Mar 2021, 09:44 AM

Hello Steve,

One easy approach to achieve this would be to pass the page as a parameter to the constructor. To do that, you would need to modify the constructor of the provider and make it accept and save the page reference. 

If you need only to access a single combobox, you can make the constructor accept a RadComboBox instance:

public class GanttCustomProvider : GanttProviderBase
{
    public RadComboBox FilterComboBox { get; set; }

    public GanttCustomProvider(RadComboBox filterCombo) : base()
    {
        this.FilterComboBox = filterCombo;
    }
   
    public override List<ITask> GetTasks()
    {
        foreach (var item in AllTasks)
        {
            item.Title += this.FilterComboBox.Text;
        }

        return AllTasks;
    }

 

And then you can change the provider creation as shown below:

RadGantt1.Provider = new GanttCustomProvider(RadComboBox1);

Regards,
Peter Milchev
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
Steve
Top achievements
Rank 1
Veteran
answered on 31 Mar 2021, 03:12 PM

Hi Peter

The radcombo now passes from the page and I can access it in the GetTasks function .. progress there.

However I want to access it in the AllTasks function so I can filter the records returned from the database before building the sessionTasks List.

VB won't let meuse Me.filterCombo it errors with  Me' is valid only within an instance method.

0
Steve
Top achievements
Rank 1
Veteran
answered on 01 Apr 2021, 12:10 PM

Solved it, the 

 

Public Property rcmbRoutingLinkCode As RadComboBox

should be 

Public Shared Property rcmbRoutingLinkCode As RadComboBox
0
Peter Milchev
Telerik team
answered on 05 Apr 2021, 09:59 AM

Hello Steve,

The solution you have is a possible approach, yes. 

The main reason you would need that is because the AllTasks is a static method so you would need to have a static reference instead of an instance one:

Another approach that I would suggest is not using the static AllTasks method at all. In general, the GetTasks() method of the provider is the one where you need to get the data, hence this is the place where you would query the data base with your filters. 

The static method in this example you probably used as a base is only for demo purposes, so you can easily remove the static AllTasks method and implement your logic inside the GetTasks() instance method where you would be able to access the RadComboBox with the code from my previous reply.

Regards,
Peter Milchev
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
Gantt
Asked by
Steve
Top achievements
Rank 1
Veteran
Answers by
Peter Milchev
Telerik team
Steve
Top achievements
Rank 1
Veteran
Share this question
or