<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="WorkCalendar.ascx.cs"
    Inherits="WebKart.ASCX.WorkCalendar" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<script type="text/javascript">
    function GridCreated(sender, eventArgs) {
        //gets the main table scrollArea HTLM element  
        var scrollArea = document.getElementById(sender.get_element().id + "_GridData");
        var row = sender.get_masterTableView().get_selectedItems()[0];

        //if the position of the selected row is below the viewable grid area  
        if (row) {
            if ((row.get_element().offsetTop - scrollArea.scrollTop) + row.get_element().offsetHeight + 20 > scrollArea.offsetHeight) {
                //scroll down to selected row  
                scrollArea.scrollTop = scrollArea.scrollTop + ((row.get_element().offsetTop - scrollArea.scrollTop) + row.get_element().offsetHeight - scrollArea.offsetHeight) + row.get_element().offsetHeight;
            }
            //if the position of the the selected row is above the viewable grid area  
            else if ((row.get_element().offsetTop - scrollArea.scrollTop) < 0) {
                //scroll the selected row to the top  
                scrollArea.scrollTop = row.get_element().offsetTop;
            }
        }
    }
</script>
<p>
    &nbsp;
</p>
<telerik:RadGrid ID="calendarGrid" runat="server" OnNeedDataSource="calendarGrid_NeedDataSource"
    OnItemDataBound="calendarGrid_ItemDataBound">
    <ClientSettings>
        <ClientEvents OnGridCreated="GridCreated" />
        <Scrolling AllowScroll="true" ScrollHeight="200px" UseStaticHeaders="true" />
    </ClientSettings>
    <MasterTableView AllowSorting="false" AllowPaging="false" AllowFilteringByColumn="false">
        <Columns>
            <telerik:GridBoundColumn DataField="Status" HeaderText="وضعیت">
                <ItemStyle Width="100px" />
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="Date" HeaderText="تاریخ">
                <ItemStyle Width="100px" />
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="WeekDay" HeaderText="روز هفته">
                <ItemStyle HorizontalAlign="Right" Width="100px" />
            </telerik:GridBoundColumn>
            <telerik:GridTemplateColumn DataField="Status" HeaderText="وضعیت" Visible="false">
                <ItemTemplate>
                    <asp:Literal ID="ltrColor" Text='<%#Eval("Color") %>' runat="server"></asp:Literal>
                </ItemTemplate>
            </telerik:GridTemplateColumn>
        </Columns>
    </MasterTableView>
</telerik:RadGrid>
