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

Refresh

Asked by St�©phane
14 years ago.

Hi

I have 2 scheduler in one page in 2 differents tab panels.

The first one is ok, that means that all events are refreshed has soon as the page is opened.

But not the second one. I have to move the horizontal bar in order to refresh it... I don't know why because the code is quite the same for both.

Her is my code:

<DayPilot:DayPilotScheduler ID="DayPilotScheduler2" runat="server"
ClientObjectName="dps2"
BackColor="#FFFFD5" BorderColor="#000000" CellBorderColor="#EAD098"
EnableViewState="false"
CellSelectColor="#316AC5" CrosshairColor="Gray" CssClass=""
DurationBarColor="Blue" EmptyBackColor="#FFFFFF"
EventBackColor="#FFFFFF" EventBorderColor="#000000" EventFontColor="0, 0, 0"
EventHeight="17" EventMoveMargin="5" EventResizeMargin="5"
HeaderFontColor="0, 0, 0" HeaderHeight="17" HourBorderColor="#EAD098"
HourNameBackColor="#ECE9D8" HourNameBorderColor="#ACA899"
LoadingLabelBackColor="Red" LoadingLabelFontColor="255, 255, 255"
NonBusinessBackColor="#FFCC66" ScrollX="0" ScrollY="0"
TimeBreakColor="#000000" WeekStarts="Monday"
DataStartField="eventstart"
DataEndField="eventend"
DataTextField="name"
DataValueField="id"
HeightSpec="Auto"
RowMinHeight="15"
DataResourceField="id" Width="1150px"
TreeEnabled="true"
TreeImageCollapse="images/tree_collapse.png"
TreeImageExpand="images/tree_expand.png"
TreeImageNoChildren="images/tree_nochildren.png"
TreeIndent="15"
CellGroupBy="Month"
EventFontSize="11px"
RowHeaderWidth="300" CellDuration="1440" CellWidth="40" Layout="Auto"
LoadingLabelText="Chargement en cours..." RowHeaderColumnWidths="300"
style="top: 0px; left: 0px" TimeFormat="Clock24Hours"
ContextMenuID="DayPilotMenu2"
UseEventBoxes="Always"
BusinessEndsHour="19" BusinessBeginsHour="8" Days="2"
ShowNonBusiness="true"
TimeRangeSelectedHandling="JavaScript"
TimeRangeSelectedJavaScript="createEvent(start, end, resource,dps2)" >

</DayPilot:DayPilotScheduler>

AND THEN the code behind

private void preloadTreeRPI()
{
//SELECT DISTINCT sVersion FROM T_FichesProjets
if (DayPilotScheduler2.Resources.Count == 0)
{
try
{
dtRPI = new DataTable();
dtRPI.Columns.Add("eventstart", typeof(DateTime));
dtRPI.Columns.Add("eventend", typeof(DateTime));
dtRPI.Columns.Add("id", typeof(string));
dtRPI.Columns.Add("name", typeof(string));
dtRPI.Columns.Add("empty", typeof(string));

// premier arbre : on charge les users de mon quipe
// deuxieme, les fiches projets par user
string[] role = System.Web.Security.Roles.GetRolesForUser(Context.User.Identity.Name);
string tousroles = "";
for (int i = 0; i <= role.Length - 1; i++)
{
tousroles += "'" + role[i] + "',";
}
tousroles = tousroles.Remove(tousroles.Length - 1);
odsMembresEquipe.FilterExpression = " Rolename IN (" + tousroles + ")";
DataView dvRoles = (DataView)odsMembresEquipe.Select();
foreach (DataRow r in dvRoles.Table.Rows)
{

Resource res = new Resource((string)r["prenom"] + " " + (string)r["nom"], (string)r["userid"].ToString());
res.ChildrenLoaded = true;
res.Expanded = true;
DayPilotScheduler2.Resources.Add(res);


SqlConnection con = new SqlConnection();
con.ConnectionString = ConfigurationManager.ConnectionStrings["PortailEDSConnectionString"].ConnectionString;

// Ouverture
con.Open();
// Objet Command
SqlDataAdapter da = new SqlDataAdapter("SELECT DISTINCT sVersion FROM T_FichesProjets", con);
// Objet DataReader
DataTable dt = new DataTable();
da.Fill(dt);

foreach (DataRow r2 in dt.Rows)
{

Resource res2 = new Resource((string)r2["sVersion"], (string)r2["sVersion"]);
res2.ChildrenLoaded = false;
res.Children.Add(res2);

loadResourcesRPI(res2, res);


}


// Fermeture connection
con.Close();

}


}
catch (SqlException e)
{
System.Diagnostics.Debug.WriteLine(e.ToString());
}
finally
{
DayPilotScheduler2.DataBind();

}

}


}

This function call the next one to show the events

private void loadResourcesRPI(Resource parent2,Resource parent)
{

try
{
//contient le parent (user)
Resource r = parent;
//contient la version
Resource r2 = parent2;
SqlConnection con = new SqlConnection();
SqlConnection con2 = new SqlConnection();
con.ConnectionString = ConfigurationManager.ConnectionStrings["PortailEDSConnectionString"].ConnectionString;
con2.ConnectionString = con.ConnectionString;

// Ouverture
con.Open();
// Objet Command
SqlDataAdapter da = new SqlDataAdapter("SELECT CONVERT(nvarchar, T_FichesProjets.nIdFP) AS id, isnull(T_FichesProjets.sFProjet + ' : ','') + T_FichesProjets.sLibelleGeneral AS name,userid FROM T_FPUser INNER JOIN T_FichesProjets ON T_FichesProjets.nIdFP = T_FPUser.nIdFP where sversion ='" + r2.Value + "' and userid = '" + r.Value + "'", con);
// Objet DataReader
DataTable dt = new DataTable();
da.Fill(dt);



foreach (DataRow dr in dt.Rows)
{
string name = (string)dr["name"];
//string id = Guid.NewGuid().ToString();
string id = "RPI|"+(string)dr["id"] +"|"+ (string)dr["userid"];
Resource child = new Resource(name, id, true);
//child.ToolTip = (string)dr["name"];
r2.Children.Add(child);
r2.Expanded = true;
r2.ChildrenLoaded = true;

//Ajout de l'evenement

SqlDataAdapter daEvent = new SqlDataAdapter("SELECT T_CRA.nIdFP AS id, isnull(T_FichesProjets.sFProjet,T_FichesProjets.sLibelleGeneral) + ' ' + T_FichesProjets.sLibelleGeneral AS name," +
" T_CRA.dDateDebutEvenement AS eventstart, T_CRA.dDateFinEvenement AS eventend "+
"FROM T_CRA INNER JOIN T_FichesProjets "+
"ON T_FichesProjets.nIdFP = T_CRA.nIdFP where userid ='" + r.Value + "' and T_CRA.nIdFP=" + (string)dr["id"] + "", con2);


DataTable dtEvent = new DataTable();
daEvent.Fill(dtEvent);
DateTime dateDebEvent ;
DateTime dateFinEvent;
foreach (DataRow rEvent in dtEvent.Rows)
{
dateDebEvent = (DateTime)rEvent["eventstart"];
dateFinEvent = (DateTime)rEvent["eventend"];
DataRow drEvent;
drEvent = dtRPI.NewRow();
drEvent["id"] = id;
drEvent["eventstart"] = dateDebEvent;
drEvent["eventend"] = dateFinEvent;
drEvent["name"] = (String)rEvent["name"];
dtRPI.Rows.Add(drEvent);
}


DayPilotScheduler2.Update(CallBackUpdateType.Full);
}

con2.Close();
// Fermeture connection
con.Close();

}
catch (SqlException exc)
{
System.Diagnostics.Debug.WriteLine(exc.ToString());
}
finally
{


}

}

All is called in page_load:

protected void Page_Load(object sender, EventArgs e)
{
if (Context.User.Identity.IsAuthenticated == false)
{
Response.Redirect("index.aspx");
}

//modification du titre
System.Web.UI.WebControls.Label lb;
lb = (System.Web.UI.WebControls.Label)Master.FindControl("lblTitre");
lb.Text = "Relev d'activit";
//Selection du bon menu
Accordion a;
a = (Accordion)Master.FindControl("MyAccordion");
a.SelectedIndex = 0;

preloadTree();
preloadTreeRPI();
if (!IsPostBack)
{

//CRA personnel
DayPilotScheduler1.StartDate = new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1);
DayPilotScheduler1.Days = DateTime.DaysInMonth(DayPilotScheduler1.StartDate.Year, DayPilotScheduler1.StartDate.Month) + DateTime.DaysInMonth(DayPilotScheduler1.StartDate.AddMonths(1).Year, DayPilotScheduler1.StartDate.AddMonths(1).Month);

DayPilotScheduler1.DataSource = dbGetEvents(DayPilotScheduler1.StartDate, DayPilotScheduler1.Days);
DayPilotScheduler1.DataBind();
DayPilotScheduler1.SetScrollX(DateTime.Today);


//rcupration des informations du user courant
string[] infoUser = FonctionsSQL.getInfoUser(Membership.GetUser(Context.User.Identity.Name).ProviderUserKey.ToString());
if (infoUser[2] == "RPI")
{
tabCRA2.Visible = true;
tabCRA3.Visible = true;
//CRA RPI : particularit : affichage par prnom/nom/FP

DayPilotScheduler2.StartDate = new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1);
DayPilotScheduler2.Days = DateTime.DaysInMonth(DayPilotScheduler2.StartDate.Year, DayPilotScheduler2.StartDate.Month) + DateTime.DaysInMonth(DayPilotScheduler2.StartDate.AddMonths(1).Year, DayPilotScheduler2.StartDate.AddMonths(1).Month);

DayPilotScheduler2.DataSource = dtRPI;

DayPilotScheduler2.DataBind();

DayPilotScheduler2.SetScrollX(DateTime.Today);
DayPilotScheduler2.Update(CallBackUpdateType.EventsOnly);
}
else
{
DayPilotScheduler2.Visible = false;
DayPilotScheduler2.Enabled = false;

tabCRA2.Visible = false;
tabCRA3.Visible = false;
}
setDataSourceAndBind();
}

}

Please let me know if someone has an idea....

Stphane

Comment posted by St&amp;#196;�&amp;amp;#169
14 years ago.

Well

I have something new.

When I put the 2nd Scheduler in the same tabPanel as the first one, it works.

How can I refresh the scheduler when I click on the panel?

Comment posted by Dan Letecky
14 years ago.

The reason is that it's not possible to set the scrollbar position on a hidden element (see also here: forums.daypilot.org/Topic.aspx/395/scrollpositionhour_not_working_with_daypilotcalendar_in_ajax).

The rendering of DayPilot Scheduler depends on setting the scrollbar position and that's why it doesn't render in the hidden panel. However, the initial rendering code has been improved in build 5.8.1941 and I believe it could work in a hidden panel as well. You can try it with the latest sandbox build.

If it still doesn't work, try invoking dps.onScroll() when activating the hidden tab using OnClientActiveTabChanged (see also F-385).

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