search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

Hide ressource parent without children

Asked by Julien
9 years ago.

Hello,

I use a filter with a dropdownlist to filter ressource of my scheduler. But when I filter it, the parent ressource without children still apear on the scheduler.

Is there a way to hide those parents after i populate all the ressources ?

This is how i load my ressource:

private void LoadResources()
{
DataTable locations = new DataManager().GetLocations();
DayPilotScheduler1.Resources.Clear();
foreach (DataRow location in locations.Rows)
{
int id = Convert.ToInt32(location["CAT_ID"]);
Resource r = new Resource((string)location["CAT_Name"], null); // using null for resources that can't be used
r.IsParent = true; // marking as parent for the case that no children are loaded
r.Expanded = true;
r.Value = id.ToString();

int Bu = Int32.Parse(BuFilter.SelectedValue.ToString());
DataTable consultants;

if (Bu == -1)
{
consultants = new DataManager().GetLocations(id);
}
else
{
consultants = new DataManager().GetLocations(id, Bu);
}

foreach (DataRow dr in consultants.Rows)
{
string fullName = (string)dr["RES_Name"] + " " + dr["RES_FirstName"].ToString();
Resource c = new Resource(fullName, Convert.ToString(dr["RES_ID"]));
c.Value = Convert.ToString(dr["RES_ID"]);
r.Children.Add(c);

}

DayPilotScheduler1.Resources.Add(r);
}

}

Thanks

Answer posted by Dan Letecky [DayPilot]
9 years ago.

How about this:

// ...
if (r.Children.Count > 0) {
  DayPilotScheduler1.Resources.Add(r); 
}
// ...

instead of:

DayPilotScheduler1.Resources.Add(r); 

You can also filter the resources on the client side:

http://doc.daypilot.org/scheduler/row-filtering/

Answer posted by Julien
9 years ago.

Thanks Dan,

I did it like this :

if (r.Children.Count < 1)
{
DayPilotScheduler1.Resources.RemoveFromTree(r);
}

It works perfectly

This question is more than 1 months old and has been closed. Please create a new question if you have anything to add.