Les diagrammes de Gantt
-
10-07-2019 - |
Question
Quelqu'un at-il déjà utilisé GTP.NET pour asp.net 3.5 de plexityhide comme tentative de coloration de cellules individuelles sur la base d'une variable obtenue d'une requête linq comme suit
PilotDataContext pilot = new PilotDataContext();
var schedule = from x in pilot.slot_tbl_Schedules select x;
foreach (var s in schedule)
{
if (s.AppointmentType == "Repair")
{
CellLayout cl = gn.GetCell(0).Layout.Clone() as CellLayout;
gn.GetCell(0).Layout = cll;
cl.BackgroundColor = Color.Red;
cl.SelectedColor = Color.Red;
}
else if (s.AppointmentType == "Service")
{
CellLayout cl = gn.GetCell(0).Layout.Clone() as CellLayout;
gn.GetCell(0).Layout = cl;
cl.BackgroundColor = Color.Blue;
}
else if (s.AppointmentType == "TravelTime")
{
CellLayout cl = gn.GetCell(0).Layout.Clone() as CellLayout;
gn.GetCell(0).Layout = cl;
cl.BackgroundColor = Color.Green;
}
else if (s.AppointmentType == "AnnualLeave")
{
CellLayout cl = gn.GetCell(0).Layout.Clone() as CellLayout;
gn.GetCell(0).Layout = cl;
cl.BackgroundColor = Color.Yellow;
}
}
la syntaxe dans l'instruction if est ce qu'ils ont recommandé de pouvoir aider à ce sujet
Merci beaucoup
La solution
Assurez-vous de définir le paramètre CellLayout.BackgroundUse = true. Sinon, la couleur d'arrière-plan est ignorée.
Et puisque vous utilisez ASP.NET, cellLayouts générera un fichier CSS, vous devez donc ajouter le nouveau CellLayouts cloné à la collection sur CellLayouts:
Gantt_ASP.Gantt.Grid.CellLayouts.Add (cl);
Autres conseils
Dim cl2 As CellLayout = TryCast(e.GridNode.GetCell(4).Layout.Clone(), CellLayout)
cl2.SelectedColor = Color.Red
cl2.FontColor = Color.Red
cl2.BackgroundColor = Color.Blue
cl2.BackgroundUse = True ' when is true background color change
e.GridNode.GetCell(4).Layout = cl2
ça fonctionne bien .....:)
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow