Radscheduler CustomRessourceElement ChildElement to small

3 Answers 50 Views
Scheduler and Reminder
Stephan
Top achievements
Rank 3
Bronze
Iron
Iron
Stephan asked on 21 Jun 2023, 02:06 PM | edited on 26 Jun 2023, 12:47 PM

Hello Support-Team,

I'm using a RadScheduler with a custom ElementProvider. I need some Help with the Elements. I wanted the name element on top and a info box right below using the rest of the free space. I made a screenshot and here is my code for the CustomElements:

 

class CustomSchedulerResourceHeaderCellElement : SchedulerResourceHeaderCellElement
{

        private readonly StackLayoutElement _container = new StackLayoutElement();
        private readonly StackLayoutElement _subContainer = new StackLayoutElement();
        private readonly LightVisualElement _nameElement = new LightVisualElement();
        private readonly LightVisualElement _infoElement = new LightVisualElement();

        protected override void CreateChildElements()
        {
            base.CreateChildElements();

            _container.StretchHorizontally = true;
            _container.StretchVertically = true;
            _container.Orientation = Orientation.Vertical;
            _container.Alignment = ContentAlignment.TopCenter;
            _container.Padding = new Padding(3);
            _container.Children.Add(_nameElement);

            _nameElement.StretchHorizontally = true;
            _nameElement.DrawImage = true;
            _nameElement.ImageLayout = ImageLayout.None;
            _nameElement.TextWrap = true;
            _nameElement.TextAlignment = ContentAlignment.TopLeft;
            _nameElement.ImageAlignment = ContentAlignment.TopLeft;
            _nameElement.TextImageRelation = TextImageRelation.ImageBeforeText;

            _container.Children.Add(_subContainer);
            _subContainer.StretchHorizontally = true;
            _subContainer.StretchVertically = true;
            _subContainer.Orientation = Orientation.Vertical;
            _subContainer.Alignment = ContentAlignment.TopCenter;
            _subContainer.Children.Add(_infoElement);

            _infoElement.StretchHorizontally = true;
            _infoElement.StretchVertically = true;
            _infoElement.TextWrap = true;
            _infoElement.TextAlignment = ContentAlignment.TopLeft;

            _infoElement.BackColor = Color.FromArgb(128, Color.LightGray);
            _infoElement.NumberOfColors = 1;
            _infoElement.DrawFill = true;
            _infoElement.Font = new Font(this.Font, FontStyle.Regular);

            this.Children.Add(_container);
            this.DrawImage = false;
            this.DrawText = false;
        }

        public override string Text
        {
            get
            {
                InitElements();
                return base.Text;
            }
            set
            {
                base.Text = value;
            }
        }

/* Some more methods for setting the text elements and the image*/
}

 

I started with only one container, but adding a subcontainer didn't do the trick. Hope you can provide me a solution.

Regards,

Stephan

3 Answers, 1 is accepted

Sort by
1
Accepted
Dinko | Tech Support Engineer
Telerik team
answered on 26 Jun 2023, 08:27 AM

Hi Stephan,

Thank you for the provided code snippet and image.

However, it is not fully clear to me how the custom cell need to look. When I use your code snippet, I got the following look.

If you want to show the gray area under the name element, you can rotate the maing StackLayoutElement. Then set the StretchHorizontally and StretchVertically of the name element to false. Here is the result:

Can you share if this works for you?

You can check the attached project which contains the code.

Regards,
Dinko | Tech Support Engineer
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

1
Dinko | Tech Support Engineer
Telerik team
answered on 27 Jun 2023, 02:17 PM

Hello Stephan,

I am happy to hear that the suggested customizations are working for you. The answer is yes, the default value for both properties is true.

Regards,
Dinko | Tech Support Engineer
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

0
Stephan
Top achievements
Rank 3
Bronze
Iron
Iron
answered on 26 Jun 2023, 12:45 PM | edited on 26 Jun 2023, 12:47 PM

Hello Dinko,

thanks for your help. This was exactly what I'm looking for. Seems that StretchVertically and StretchHorizontally are by default true?

I think that i made some tries with commenting out that lines. But setting it to false did the trick.

 

Regards,

Stephan

 

Tags
Scheduler and Reminder
Asked by
Stephan
Top achievements
Rank 3
Bronze
Iron
Iron
Answers by
Dinko | Tech Support Engineer
Telerik team
Stephan
Top achievements
Rank 3
Bronze
Iron
Iron
Share this question
or