Filter Resources by Visibility

2 posts, 0 answers
  1. Daniel
    Daniel avatar
    19 posts
    Member since:
    Nov 2010

    Posted 23 Mar 2011 Link to this post

    Hi

    I want to use the grouping function of radScheduler to only group visible resources.
    But it does not work, it always shows all resources.
    What am I doing wrong?

    *** sample code loading Resources

                Resource tempResource = null;

                recResourceGroup[] resourceGroups = plannerSettings.recResourceGroup;
                foreach (recResourceGroup resourceGroup in resourceGroups)
                {
                    tempResource = new Resource("G-"+resourceGroup.No,resourceGroup.Name);
                    tempResource.Visible = false;
                    tempResource.Color = Color.Orange;
                    plannerSchedule.Resources.Add(tempResource);

                    recResource[] resources = resourceGroup.recResource;
                    foreach (recResource resource in resources)
                    {
                        string sKey = resource.IsRentalItem.ToString() == "1" ? "M" : "R";
                        sKey += resource.VirtualResource.ToString() == "1" ? "V-" : "-";
                        tempResource = new Resource(sKey+resource.No,resource.Name);
                        tempResource.Visible = false;
                        tempResource.Color = Color.Green;
                        plannerSchedule.Resources.Add(tempResource);
                    }
                }

    *** sample code loading Appointment-Resources

    foreach (recResourceAssigned planningAssignedResource in planningAssignedResources)
    {
        string sKey = null;
        switch (planningAssignedResource.Type.ToString())
        {
            case "0":  //resource
                {
                    sKey = "R-" + planningAssignedResource.No.ToString();
                }
                break;
            case "1":  //resourceGroup
                {
                    sKey = "G-" + planningAssignedResource.No.ToString();
                }
                break;
            case "2":  //workPlace
                {
                    sKey = "W-" + planningAssignedResource.No.ToString();
                }
                break;
            default:
                {
                    //error not supported
                }
                break;
        };
        schedulerApp.ResourceIds.Add(plannerSchedule.Resources.GetById(sKey).Id);
    }

    *** Sample code switching visibility of Resources

      foreach (Resource resource in radScheduler1.Resources)
      {
          string tempKey = resource.Id.KeyValue.ToString();
          switch(groupby)
          {
              case "resource":
                  resource.Visible = tempKey.Contains("R-") ? true : false;
                  break;
              case "resourceGroup":
                  resource.Visible = tempKey.Contains("G-") ? true : false;
                  break;
              case "workplace":
                  resource.Visible = tempKey.Contains("W-") ?  true : false;
                  break;
              case "order":
                  resource.Visible = tempKey.Contains("J-") ? true : false;
                  break;
             default:
                  resource.Visible = false;
                  break;
           }
    ...
      

     

     

    radScheduler1.RepaintElements();

     

     

     


    any ideas?
    Daniel

  2. Dobry Zranchev
    Admin
    Dobry Zranchev avatar
    348 posts

    Posted 28 Mar 2011 Link to this post

    Hello Daniel,

    Thank you for writing.

    RadScheduler does not filter the resources by their visibility. If you want to hide some of the resources, you should to remove them from the Resources collection of RadScheduler. When you want to use them again, you should just add them to the same collection.

    In case that you have other related questions, do not hesitate to write back.

    Regards,
    Dobry Zranchev
    the Telerik team
  3. UI for WinForms is Visual Studio 2017 Ready
Back to Top