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

Scheduler CellWidth as percentage

Asked by Joshua
14 years ago.

The schulder with can be set with a percentage. So I can for example, set it to occupy 100% of the parent container. The CellWidth however, has to be specified in pixels. What usually happens is I get a gray outline where the scheduler itself renders to, but the space is inused unless their are enough cells or the cell width is exactly big enough to occupy this space (without getting horizontal scrollbar).

Because non business hours in the scheduler can now be turned off, the number of cells visible is going to change according to the the number of hours set. I usually end up with cells not rendering (i.e. occupying the entire scheduler).

For example, if I am viewing a schedule that displays 12 hours in 30minute increments I have 12x2=24 time columns.

Since CellWidth cannot be set as a percentage of total is there any way to always have the 24 cells for example, occupy the entire scheduler space. For example when resizing div, browser etc.

Unless I'm missing something, this issue seems to greatly reduce the need for a percentage setting in the scheduler itself.

Cheers,

Comment posted by Joshua
14 years ago.

For the moment I am using JQuery to pass through the containing div size.

// Resizes the scheduler cell width on browswer resize.
// Uses concurrency principal to wait a period of
// time and fire one update at the end of, or pause of,resizing.
$(document).ready(function() {
function resizeScheduler() {
var newSchedulerWidth = $("#SchedulerContainer").width() - 270;
dps1.refreshCallBack(null, null, newSchedulerWidth);
}

var timeout = false;
$(window).resize(function(){
if(timeout !== false)
clearTimeout(timeout);
timeout = setTimeout(resizeScheduler, 300); // 300 millis
});
});

In the code behind I'm using the scheduler refresh callback to update the cell width with something similar to

protected void DayPilotScheduler1_Refresh(object sender, RefreshEventArgs e)
{
string s = e.Data.ToString();
int width = Int32.Parse(s);
width /= 26; // Num cells
DayPilotScheduler1.CellWidth = width;
DayPilotScheduler1.DataBind();
DayPilotScheduler1.Update(CallBackUpdateType.Full);
}

It's not perfect, as width is truncated from double to int. Over a long period of cells, depending on the resultant width, you can end up losing a few pixels at the end. There are a few enhancements you could make to this, but it works 'ok' for the moment.

Comment posted by Dan Letecky
14 years ago.

Thanks for posting your solution.

The genuine percentage support for CellWidth would be difficult but there could be a mode that would calculate the width to fit into the control width without scrolling.

Comment posted by Joshua
14 years ago.

Yep that would be ideal as doing it via the aforementioned work around isn't very clean / ideal. I'm having a few problems with both vert/horizontal scrollbars being added to the scheduler itself.

Comment posted by Joshua
14 years ago.

"....but there could be a mode that would calculate the width to fit into the control width without scrolling"

Just wondering if there is any update on this? I'm aware that you have to priotise new features and bug fixes and was wondering if there is even any plan to put this on the roadmap?

With the ability to toggle visibility of columns, show/hide non-bussines hours etc. the total width of the columns is changing a lot more resulting in small columns (with extra scheduler space) or too small scheduler (with nasty scroll bars).

Lastly, another key feature I'm hoping to see in at some stage is the ability to integrate with the scheduler and add extra rows and columns; allowing you to customise the control to a specific domain a bit better. I would like to be able to add totals columns etc.

Keep up the great work!

Cheers,

Comment posted by Joshua
14 years ago.

I should also note, that I played around with the javascript resizing idea above a bit futher but had too many issues. So I'm waiting and hoping for the aforementioned feature ;)

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