Hi Piyush,
Unfortunately fixed-size Appointments cannot be achieved only with CSS.
On the other hand,
this could be achieved with server-side code only. A limitation of this approach is that the maximum width of
Appointments should be defined in percentage and not in pixels.
In any case, below is the implementation of the approach for you to examine it.
Hook on the AppointmentCreated server-side event of RadScheduler and implement it as follows:
private const int MAX_PERCENTAGE_APPOINTMENT_WIDTH = 10; |
private bool _lastAppIsModified = false; |
|
protected void RadScheduler1_AppointmentCreated(object sender, AppointmentCreatedEventArgs e) |
{ |
double widthPercentage = e.Appointment.AppointmentControls[0].Width.Value; |
int leftPercentage = |
Int32.Parse(e.Appointment.AppointmentControls[0].Style["left"].Replace("%", String.Empty)); |
|
int widthLeftRatio = (int) Math.Ceiling(leftPercentage / widthPercentage); |
|
if (leftPercentage == 0) |
{ |
_lastAppIsModified = false; |
} |
|
if (widthPercentage > MAX_PERCENTAGE_APPOINTMENT_WIDTH) |
{ |
if ((leftPercentage == 0) || |
((leftPercentage > 0) && (_lastAppIsModified == true))) |
{ |
Unit width = Unit.Percentage(MAX_PERCENTAGE_APPOINTMENT_WIDTH); |
|
e.Appointment.AppointmentControls[0].Width = width; |
|
string leftValue = (MAX_PERCENTAGE_APPOINTMENT_WIDTH * widthLeftRatio).ToString() + "%"; |
|
e.Appointment.AppointmentControls[0].Style["left"] = leftValue; |
|
_lastAppIsModified = true; |
} |
} |
} |
The MAX_PERCENTAGE_APPOINTMENT_WIDTH variable lets you define the maximum width of Appointments in percentage.
The second variable is just a helper for the function below to catch
the final Appointment in a row of Appointments with width, less than
the maximum defined.
Finally, remove the CSS you were previously using to fix the width.
I hope this you will find useful.
Greetings,
Simon
the Telerik team