This sample Visual Studio 2012 project shows how to enable column sorting in the DayPilot ASP.NET scheduler control.
The column sorting can be activated by adding a hyperlink (<a> tag) to the column header:
<DayPilot:DayPilotScheduler ID="DayPilotScheduler1" runat="server" ... ClientObjectName="dps" OnCommand="DayPilotScheduler1_Command" > <HeaderColumns> <DayPilot:RowHeaderColumn Title="<a href='javascript:dps.commandCallBack("sort", { field: "name" }); '>Name</a>" Width="80" /> <DayPilot:RowHeaderColumn Title="<a href='javascript:dps.commandCallBack("sort", { field: "id" }); '>Id</a>" Width="80" /> </HeaderColumns> </DayPilot:DayPilotScheduler>
The commandCallBack() call will invoke Command event handler on the server side.
The event handler will reload the resources using the new order.
C#
protected void DayPilotScheduler1_Command(object sender, CommandEventArgs e) { switch (e.Command) { case "sort": LoadResources((string)e.Data["field"]); DayPilotScheduler1.DataSource = GetData(DayPilotScheduler1.StartDate, DayPilotScheduler1.EndDate.AddDays(1)); DayPilotScheduler1.DataBind(); DayPilotScheduler1.Update(); break; } }
VB
Protected Sub DayPilotScheduler1_Command(ByVal sender As Object, ByVal e As CommandEventArgs) Select Case e.Command Case "sort" LoadResources(CStr(e.Data("field"))) DayPilotScheduler1.DataSource = GetData(DayPilotScheduler1.StartDate, DayPilotScheduler1.EndDate.AddDays(1)) DayPilotScheduler1.DataBind() DayPilotScheduler1.Update() End Select End Sub
The tutorial source code (C#, VB) is available for download.