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

Filter Scheduler Resources using radDropdownlist

2 Answers 138 Views
Scheduler and Reminder
This is a migrated thread and some comments may be shown as answers.
Tom Graham
Top achievements
Rank 1
Tom Graham asked on 14 Apr 2016, 08:47 PM

I have a Scheduler instance in TimeLine view using Resource grouping. I would like to take a radDropdownlist control and give the user the ability to filter the scheduler to just resources he/she is responsible for on the scheduler. Has anyone be able to filter the resources in Scheduler?

 

Thanks,

 

TomG

2 Answers, 1 is accepted

Sort by
0
Accepted
Dess | Tech Support Engineer, Principal
Telerik team
answered on 15 Apr 2016, 10:12 AM
Hello Tom,

Thank you for writing.

Your question has already been answered in the support thread you have opened on the same topic. However, I am posting the answer here as well in order the community to benefit from it. In order to filter the resources in RadScheduler, you can set the new DataSource with the filtered data. Here is a sample code snippet demonstrating how to filter the resources by using a RadCheckedDropDownList:
DataTable dt = new DataTable();
SchedulerBindingDataSource schedulerBindingDataSource = new SchedulerBindingDataSource();
ResourceMappingInfo resourceMappingInfo = new ResourceMappingInfo();
  
public Form1()
{
    InitializeComponent();
    
    dt.Columns.Add("Id", typeof(int));
    dt.Columns.Add("Name", typeof(string));
    dt.Columns.Add("Color", typeof(Color));
    for (int i = 1; i <= 10; i++)
    {
        dt.Rows.Add(i, "Resource" + i, Color.Yellow);
    }
  
    resourceMappingInfo.Id = "Id";
    resourceMappingInfo.Name = "Name";
    resourceMappingInfo.Color = "Color";
    schedulerBindingDataSource.ResourceProvider.Mapping = resourceMappingInfo;
    schedulerBindingDataSource.ResourceProvider.DataSource = dt;
    this.radScheduler1.DataSource = schedulerBindingDataSource;
    this.radScheduler1.GroupType = GroupType.Resource;
    this.radScheduler1.ActiveView.ResourcesPerView = dt.Rows.Count;
  
    this.radCheckedDropDownList1.DataSource = dt;
    this.radCheckedDropDownList1.DisplayMember = "Name";
    this.radCheckedDropDownList1.ValueMember = "Id";
    foreach (RadCheckedListDataItem item in this.radCheckedDropDownList1.Items)
    {
        item.Checked = true;
    }
  
    this.radCheckedDropDownList1.ItemCheckedChanged += radCheckedDropDownList1_ItemCheckedChanged;
}
  
private void radCheckedDropDownList1_ItemCheckedChanged(object sender, RadCheckedListDataItemEventArgs e)
{
    StringBuilder sb = new StringBuilder();
    foreach (RadCheckedListDataItem item in this.radCheckedDropDownList1.CheckedItems)
    {
        sb.Append("Id = " + item.Value + " or ");
    }
    sb.Remove(sb.Length - 3, 2);
    DataView dv = new DataView(dt);
    dv.RowFilter = sb.ToString();
    schedulerBindingDataSource.ResourceProvider.DataSource = dv;
}

I hope this information helps. Should you have further questions I would be glad to help.

 Regards,
Dess
Telerik
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
Tom Graham
Top achievements
Rank 1
answered on 16 Apr 2016, 12:53 AM
That put me on the right track.Thanks for the information.
Tags
Scheduler and Reminder
Asked by
Tom Graham
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Tom Graham
Top achievements
Rank 1
Share this question
or