Filter Scheduler Resources using radDropdownlist

3 posts, 1 answers
  1. Tom Graham
    Tom Graham avatar
    6 posts
    Member since:
    Mar 2010

    Posted 14 Apr Link to this post

    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. Answer
    Dess
    Admin
    Dess avatar
    1607 posts

    Posted 15 Apr Link to this post

    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.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Tom Graham
    Tom Graham avatar
    6 posts
    Member since:
    Mar 2010

    Posted 15 Apr in reply to Dess Link to this post

    That put me on the right track.Thanks for the information.
Back to Top