This is a migrated thread and some comments may be shown as answers.

RadGrid table view

5 Answers 122 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Olga
Top achievements
Rank 1
Olga asked on 11 Feb 2014, 12:03 AM
Hello, I have a page with multiple tables, and view of one of the table change after I add rows to it's child table. Does anybody know what issue can cause it. I don't have a errors, not in the compiler not in the browser. It stops highlighting the parent row, maybe instead it's trying to do some thing else ....

5 Answers, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 13 Feb 2014, 08:02 PM
Hi Olga,

From the provided screenshots and information it is really hard to determine what is your exact scenario and how the grids are related to each other.

Could you please elaborate on your scenario, the page structure and the relationships between the grids.

I am looking forward to your reply.


Regards,
Konstantin Dikov
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the UI for ASP.NET AJAX, subscribe to the blog feed now.
0
Olga
Top achievements
Rank 1
answered on 13 Feb 2014, 09:13 PM
Thank you for the response. Here the code for second, third and the 4th tables from this page.
<%@ Page Title="" Language="C#" MasterPageFile="~/CallCenter_Web/MasterPage.master" AutoEventWireup="true" CodeFile="Company.aspx.cs" Inherits="CallCenter_Web_Company" %>
<%@ Register TagPrefix="My" TagName="UserProductControl" Src="~/Dialogs/productControl.ascx" %>
<%@ Register TagPrefix="My" TagName="UserDepartmentControl" Src="~/Dialogs/DepartmentControl.ascx" %>
 
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <style>
        TimeCss {
            color: red !important;
        }
 
    </style>
    <telerik:RadScriptManager ID="script" runat="server" >
        <Scripts>
           <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
           <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" />
       </Scripts>
    </telerik:RadScriptManager>
 
    <My:UserProductControl ID ="UserProductControl" runat="server" Visible="false" ></My:UserProductControl>
    <My:UserDepartmentControl ID ="UserDepartmentControl" runat="server" Visible="false" ></My:UserDepartmentControl>
 
    <center><h2 style="font-size:25px;margin-top: 75px;">Company</h2></center><br />
 
      
    <telerik:RadCodeBlock ID="code" runat="server">
        <script>
 
            $(function () {
                $("#dialog").dialog();
            });
            $(document).ready(function () {
            });
 
            function OnClientClose(oWnd, args) {
                RefreshGrid();
            }
 
            function RefreshGrid() {
                var masterTable = $find("<%= RadGrid.ClientID %>").get_masterTableView();
                masterTable.rebind();
            }
 
 
        </script>
         
    </telerik:RadCodeBlock>
 
 
    <div>
 
.....
 
    <telerik:RadGrid ID="RadGrid" AllowFilteringByColumn="true" runat="server" AllowPaging="true"
        PageSize="15" AutoGenerateColumns="false" ShowStatusBar="true" AllowSorting="true"
        OnUpdateCommand="RadGrid_UpdateCommand"
        OnNeedDataSource="RadGrid_NeedDataSource"
        OnInsertCommand="RadGrid_InsertCommand"
        OnItemCreated="RadGrid_ItemCreated"
        OnDeleteCommand="RadGrid_DeleteCommand"
        OnItemCommand="RadGrid_ItemCommand" Width="900px">
        <MasterTableView
            DataKeyNames="id,companyClientId, productId"
            CommandItemDisplay="Top"
            EditMode="PopUp"
            EditFormSettings-PopUpSettings-ShowCaptionInEditForm="true"
            EditFormSettings-PopUpSettings-Modal="true">
            <CommandItemSettings
                ShowAddNewRecordButton="true"
                ShowExportToCsvButton="true"
                AddNewRecordText="New Product Request"
                ShowRefreshButton="true" />           
            <Columns>
                <telerik:GridEditCommandColumn ButtonType="ImageButton" HeaderText="Edit"></telerik:GridEditCommandColumn>
                <telerik:GridButtonColumn CommandName="delete" ConfirmText="Do you really want to delete this Department?"
                    ButtonType="ImageButton" ImageUrl="~/images/cancel.png" Visible="false" ItemStyle-ForeColor="Black" HeaderText="Delete">
                </telerik:GridButtonColumn>
                <telerik:GridButtonColumn CommandName="contract" ButtonType="LinkButton" Text="Contract" HeaderText="Contract">
                </telerik:GridButtonColumn>
                <telerik:GridButtonColumn CommandName="task" ButtonType="LinkButton" Text="Task" HeaderText="Task">
                </telerik:GridButtonColumn>
                <telerik:GridButtonColumn CommandName="report" ButtonType="LinkButton" Text="Report" HeaderText="Report">
                </telerik:GridButtonColumn>
                <telerik:GridBoundColumn DataField="id" UniqueName="id" HeaderText="ID" ReadOnly="true" Visible="false">
                </telerik:GridBoundColumn>
                <telerik:GridTemplateColumn DataField="companyClientId" EditFormColumnIndex="0"
                    ReadOnly="false" Visible="false" HeaderText="Company"
                    UniqueName="companyClientId">
                    <ItemTemplate>
                        <asp:Label ID="clientLabel" runat="server" Text='<%# Bind("clientCompany") %>'></asp:Label>
                    </ItemTemplate>
                    <EditItemTemplate>
                        <telerik:RadComboBox ID="clientCombo" runat="server" DataSourceID="DS_Company"
                            DataTextField="name" DataValueField="id">
                        </telerik:RadComboBox>
                    </EditItemTemplate>
                </telerik:GridTemplateColumn>
                <telerik:GridBoundColumn DataField="prName" UniqueName="prName" HeaderText="Project Name" EditFormColumnIndex="0">
                </telerik:GridBoundColumn>
                <telerik:GridTemplateColumn DataField="productId" HeaderText="Product" UniqueName="productId"  EditFormColumnIndex="0">
                    <ItemTemplate>
                        <asp:Label ID="productLabel" runat="server" Text='<%# Bind("product") %>'></asp:Label>
                    </ItemTemplate>
                    <EditItemTemplate>
                        <telerik:RadComboBox ID="productCombo" runat="server" DataSourceID="DS_Products"
                            DataTextField="product" DataValueField="id"
                            SelectedValue='<%# Eval("productId")==DBNull.Value?"5":Eval("productId") %>'>
                        </telerik:RadComboBox>
                        <telerik:RadButton id ="addProd" runat="server" ButtonType="StandardButton" text ="+" Autopostback =" true"
                            onclick ="addNewProd_Click" CommandName ="addProd" ></telerik:RadButton>
                    </EditItemTemplate>
                </telerik:GridTemplateColumn>               
                <telerik:GridTemplateColumn DataField="departmentId" HeaderText="Department"
                     UniqueName="departmentId" Visible="false" EditFormColumnIndex="0">
                    <ItemTemplate>
                        <asp:Label ID="deptLabel" runat="server" Text='<%# Bind("depCode") %>'></asp:Label>
                    </ItemTemplate>
                    <EditItemTemplate>
                        <telerik:RadComboBox ID="deptCombo" runat="server" DataSourceID="DS_Dept"
                            DataTextField="name" DataValueField="id"
                            SelectedValue='<%# Eval("departmentId")==DBNull.Value?"1":Eval("departmentId") %>'>
                        </telerik:RadComboBox>
                        <telerik:RadButton id ="addDep" runat="server" ButtonType="StandardButton" text ="+" Autopostback =" true"
                            onclick ="addNewDep_Click" CommandName ="addDep" ></telerik:RadButton>
                    </EditItemTemplate>
                </telerik:GridTemplateColumn>
                <telerik:GridBoundColumn DataField="productRequestConfirmerId" UniqueName="productRequestConfirmerId"
                    HeaderText="Request Confirmed By" Visible="false" ReadOnly="true" EditFormColumnIndex="0">
                </telerik:GridBoundColumn>              
                <telerik:GridTemplateColumn HeaderText="Project Manager" UniqueName="projectManagerId" EditFormColumnIndex="0" AllowFiltering =" false">
                    <ItemTemplate>
                        <asp:Label ID="projectManagerLabel" runat="server" Text='<%# Bind("projectManagerName") %>'></asp:Label>
                    </ItemTemplate>
                    <EditItemTemplate>
                        <telerik:RadComboBox ID="projectManagerCombo" runat="server" DataSourceID="DS_Employee"
                            DataTextField="name" DataValueField="id" SelectedValue='<%# Eval("projectManagerId") %>'>
                        </telerik:RadComboBox>
                    </EditItemTemplate>
                </telerik:GridTemplateColumn>
                <telerik:GridTemplateColumn HeaderText="Lead Developer" UniqueName="leadDeveloperId" EditFormColumnIndex="0" AllowFiltering =" false">
                    <ItemTemplate>
                        <asp:Label ID="leadDeveloperLabel" runat="server" Text='<%# Bind("leadDeveloperName") %>'></asp:Label>
                    </ItemTemplate>
                    <EditItemTemplate>
                        <telerik:RadComboBox ID="leadDeveloperCombo" runat="server" DataSourceID="DS_Employee"
                            DataTextField="name" DataValueField="id" SelectedValue='<%# Eval("leadProgrammerId") %>'>
                        </telerik:RadComboBox>
                    </EditItemTemplate>
                </telerik:GridTemplateColumn>
               <telerik:GridTemplateColumn DataField="requestedById" HeaderText="Involved Employees" UniqueName="requestedById"
                 AllowFiltering =" false"    EditFormColumnIndex="0">
                    <ItemTemplate>
                        <telerik:RadComboBox ID ="empAddCombo" runat="server" DataTextField="employee">
                        </telerik:RadComboBox>
                    </ItemTemplate>
                    <EditItemTemplate
                        <telerik:RadComboBox ID="empCombo"
                            runat="server"
                            CheckBoxes="true"
                             EmptyMessage="Select related employee"
                            CheckedItemsTexts="DisplayAllInInput">                           
                        </telerik:RadComboBox>                      
                    </EditItemTemplate>
                </telerik:GridTemplateColumn>
                <telerik:GridDateTimeColumn DataField="contractSentDate" UniqueName="contractSentDate" Visible="false"
                     HeaderText="Contract Sent" DataFormatString="{0:MMM dd, yyyy}" FilterControlWidth="80px" EditFormColumnIndex="1">
                </telerik:GridDateTimeColumn>               
                <telerik:GridDateTimeColumn DataField="contractSignedDate" UniqueName="contractSignedDate" Visible="false"
                    HeaderText="Contract Signed" DataFormatString="{0:MMM dd, yyyy}" FilterControlWidth="80px" EditFormColumnIndex="1">
                </telerik:GridDateTimeColumn>
                <telerik:GridDateTimeColumn DataField="depositReceivedDate" UniqueName="depositReceivedDate" Visible="false"
                    HeaderText="Deposit Received" DataFormatString="{0:MMM dd, yyyy}" FilterControlWidth="80px" EditFormColumnIndex="1">
                </telerik:GridDateTimeColumn>
                <telerik:GridDateTimeColumn DataField="startDate" UniqueName="startDate"
                    HeaderText="Start Date" DataFormatString="{0:MMM dd, yyyy}" FilterControlWidth="80px" EditFormColumnIndex="1">
                </telerik:GridDateTimeColumn>
                <telerik:GridNumericColumn DataField="daysToFinish" UniqueName="daysToFinish" HeaderText="Days To Finish"
                    FilterControlWidth="50px" AllowFiltering="false" EditFormColumnIndex="1">
                </telerik:GridNumericColumn>
                <telerik:GridBoundColumn DataField="depositAmount" UniqueName="depositAmount" Visible="false"
                    HeaderText="Deposit" DataFormatString="{0:C}" FilterControlWidth="50px" AllowFiltering="false" EditFormColumnIndex="1">
                </telerik:GridBoundColumn>
                <telerik:GridDateTimeColumn DataField="expectedDeliveryDate" UniqueName="expectedDeliveryDate" Visible="true"
                    HeaderText="Expected Delivery" DataFormatString="{0:MMM dd, yyyy}" FilterControlWidth="80px" EditFormColumnIndex="1">
                </telerik:GridDateTimeColumn>
                <telerik:GridDateTimeColumn DataField="deliveryDate" UniqueName="deliveryDate"  Visible="false"
                    HeaderText="Delivery" DataFormatString="{0:MMM dd, yyyy}" FilterControlWidth="80px" EditFormColumnIndex="1">
                </telerik:GridDateTimeColumn>
                <telerik:GridDateTimeColumn DataField="goLiveDate" UniqueName="goLiveDate" Visible="false"
                    HeaderText="Go live" DataFormatString="{0:MMM dd, yyyy}" FilterControlWidth="80px" EditFormColumnIndex="1">
                </telerik:GridDateTimeColumn>
                <telerik:GridBoundColumn DataField="estimatedCost" UniqueName="estimatedCost"
                    HeaderText="Estimated Cost" DataFormatString="{0:C}" AllowFiltering="false" EditFormColumnIndex="1">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="actualCost" UniqueName="actualCost" HeaderText="Actual Cost"
                    DataFormatString="{0:C}" AllowFiltering="false" EditFormColumnIndex="2" Visible="false">
                </telerik:GridBoundColumn>
                <telerik:GridDateTimeColumn DataField="estimatedDate" UniqueName="estimatedDate" Visible="false"
                    HeaderText="Estimated Date" DataFormatString="{0:MMM dd, yyyy}" FilterControlWidth="80px" EditFormColumnIndex="2">
                </telerik:GridDateTimeColumn>
                <telerik:GridTemplateColumn DataField="statusId" HeaderText="Status"  AllowFiltering =" false"
                    UniqueName="statusId"  FilterControlWidth="40px" EditFormColumnIndex="2">
                    <ItemTemplate>
                        <asp:Label ID="statusLabel" runat="server" Text='<%# Bind("status") %>'></asp:Label>
                    </ItemTemplate>
                    <EditItemTemplate>
                        <telerik:RadComboBox ID="statusCombo" runat="server" DataSourceID="DS_Status"
                            DataTextField="description" DataValueField="id"
                            SelectedValue='<%# Eval("statusId")==DBNull.Value?"2":Eval("statusId") %>'>
                        </telerik:RadComboBox>
                    </EditItemTemplate>
                </telerik:GridTemplateColumn>
                <telerik:GridCheckBoxColumn DataField="paidInFull" UniqueName="paidInFull" HeaderText="Full Paid?" AllowFiltering ="false" EditFormColumnIndex="2">
                </telerik:GridCheckBoxColumn>
                <telerik:GridTemplateColumn EditFormColumnIndex="2" HeaderText="Paid By" UniqueName="paidById" ReadOnly="false">
                    <ItemTemplate>
                        <asp:Label ID="paidByLabel" runat="server" Text='<%# Bind("paidByName") %>'></asp:Label>
                    </ItemTemplate>
                    <EditItemTemplate>
                        <telerik:RadComboBox ID="paidByCombo" runat="server" DataSourceID="DS_PaidBy"
                            DataTextField="name" DataValueField="id"
                            SelectedValue ='<%# Eval("paidById")==DBNull.Value?"5":Eval("paidById") %>'>
                        </telerik:RadComboBox>
                    </EditItemTemplate>
                    <EditItemTemplate>
                        <telerik:RadComboBox ID="paidByCombo" runat="server" DataSourceID="DS_PaidBy" DataTextField="name"
                            DataValueField="id" SelectedValue='<%# Eval("paidById") %>'>
                        </telerik:RadComboBox>
                    </EditItemTemplate>
                </telerik:GridTemplateColumn>
                <telerik:GridCheckBoxColumn DataField="taskScheduleComplete" UniqueName="taskScheduleComplete"
                    HeaderText="Task Schedule Complete?" AllowFiltering ="false" EditFormColumnIndex="2">
                </telerik:GridCheckBoxColumn>
                <telerik:GridTemplateColumn UniqueName="note" DataField="note" HeaderText="Notes" AllowFiltering="false" EditFormColumnIndex="2">
                    <ItemTemplate>
                        <asp:Label ID="notesLabel" runat="server" Text='<%# Bind("note") %>'></asp:Label>
                    </ItemTemplate>
                    <EditItemTemplate>
                        <asp:TextBox ID="notesText" runat="server" TextMode="MultiLine" Rows="7"
                            Text='<%# Bind("note") %>'></asp:TextBox>
                    </EditItemTemplate>
                </telerik:GridTemplateColumn>               
            </Columns>
            <EditFormSettings ColumnNumber="3" FormStyle-Width="900px">
                <PopUpSettings Width="860px" />
            </EditFormSettings>
        </MasterTableView>
        <ClientSettings>
                <ClientEvents OnPopUpShowing="PopUpShowing" />
            </ClientSettings>
    </telerik:RadGrid>
 
        <telerik:RadGrid ID="projectTasks" AllowFilteringByColumn="true" runat="server" AllowPaging="true"
            PageSize="5" AutoGenerateColumns="false" ShowStatusBar="true" AllowSorting="true"
            OnUpdateCommand="projectTasks_UpdateCommand"
            OnItemCreated="projectTasks_ItemCreated"
            OnInsertCommand="projectTasks_InsertCommand"
            OnDeleteCommand="projectTasks_DeleteCommand"
            OnItemCommand="projectTasks_ItemCommand" 
            OnPreRender="projectTasks_PreRender">
            <MasterTableView CommandItemDisplay="Top" DataKeyNames="id"
                EditMode="PopUp" EditFormSettings-PopUpSettings-Modal="true" PagerStyle-AlwaysVisible="true">
                <CommandItemSettings AddNewRecordText="Add Project Tasks" ShowAddNewRecordButton="true" ShowExportToCsvButton="true"
                    ShowRefreshButton="true" />          
                <Columns>
                    <telerik:GridEditCommandColumn ButtonType="ImageButton" Visible="true" HeaderStyle-Width="2%" HeaderText="Edit">
                    </telerik:GridEditCommandColumn>
                    <telerik:GridButtonColumn UniqueName="delete" CommandName="delete" ButtonType="ImageButton" ImageUrl="~/images/cancel.png" HeaderText="Delete"
                        ConfirmText="Are you sure you want to delete this data?" HeaderStyle-Width="2%">
                    </telerik:GridButtonColumn>
                    <telerik:GridButtonColumn UniqueName="history" CommandName="history" HeaderText="History"
                        ButtonType="LinkButton" Text="History">
                    </telerik:GridButtonColumn>
                    <telerik:GridButtonColumn UniqueName="subtask" CommandName="subtask" HeaderText="Sub Taks"
                        ButtonType="LinkButton" Text="Subtask">
                    </telerik:GridButtonColumn>
                    <telerik:GridBoundColumn DataField="id" UniqueName="id" HeaderText="ID" ReadOnly="true" Visible="false">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="productRequestId" UniqueName="productRequestId"
                        HeaderText="productRequestId" ReadOnly="true" Visible="false">
                    </telerik:GridBoundColumn>               
                    <telerik:GridBoundColumn DataField="TaskName" UniqueName="TaskName" Visible="true" ReadOnly="false"
                         HeaderText="Task Name" AllowFiltering ="false">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="description" UniqueName="description" Visible="true" ReadOnly="false"
                         HeaderText="Description" AllowFiltering ="false">
                    </telerik:GridBoundColumn>                   
                    <telerik:GridDateTimeColumn DataField="startDate" UniqueName="startDate" HeaderText="Start Date"
                         FilterControlWidth="100px" DataFormatString="{0:MMM dd, yyyy}" EditFormColumnIndex="0">
                    </telerik:GridDateTimeColumn>
                     
                    <telerik:GridNumericColumn UniqueName="noOfDays" DataField="noOfDays" HeaderText="Duration" AllowFiltering ="false" FilterControlWidth="25px">
                    </telerik:GridNumericColumn>
                    <telerik:GridTemplateColumn EditFormColumnIndex="0" HeaderText="Depend Task" UniqueName="DependTaskId" AllowFiltering ="false"
                        HeaderStyle-Width="200px">
                        <ItemTemplate>
                            <asp:Label ID="prodLabel" runat="server" Text='<%# Bind("DependTaskName") %>'></asp:Label>
                            
                        </ItemTemplate>
                        <EditItemTemplate>
                            <telerik:RadComboBox ID="dependTaskIdCombo" runat="server" ></telerik:RadComboBox>
                        </EditItemTemplate>
                    </telerik:GridTemplateColumn>
                    <telerik:GridNumericColumn UniqueName="gap" AllowFiltering ="false" DataField="gap" HeaderText="Gap" FilterControlWidth="25px">
                    </telerik:GridNumericColumn>
                    <telerik:GridDateTimeColumn DataField="endDate" UniqueName="endDate" HeaderText="End Date"
                         FilterControlWidth="100px" DataFormatString="{0:MMM dd, yyyy}" ReadOnly="true">
                    </telerik:GridDateTimeColumn>
                    <telerik:GridTemplateColumn EditFormColumnIndex="0" HeaderText="Held By" UniqueName="heldContactId"
                        HeaderStyle-Width="200px">
                        <ItemTemplate>
                            <asp:Label ID="heldLabel" runat="server" Text='<%# Bind("heldContactName") %>'></asp:Label>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <telerik:RadComboBox ID="heldCombo" runat="server" DataSourceID="DS_Employee"
                                    DataTextField="name" DataValueField="id" SelectedValue='<%# Eval("heldContactId") %>'>
                            </telerik:RadComboBox>
                        </EditItemTemplate>
                    </telerik:GridTemplateColumn>
                    <telerik:GridDateTimeColumn DataField="modifiedDate" UniqueName="modifiedDate" HeaderText="Modified Date"
                         FilterControlWidth="100px" DataFormatString="{0:MMM dd, yyyy}">
                    </telerik:GridDateTimeColumn>
                    <telerik:GridBoundColumn UniqueName="budget" AllowFiltering ="false" DataField="budget" HeaderText="Budget"
                        FilterControlWidth="30px" DataFormatString="{0:C}">
                    </telerik:GridBoundColumn>                  
                    <telerik:GridTemplateColumn DataField="notes" AllowFiltering ="false" UniqueName="notes" HeaderText="Notes">
                        <itemtemplate>
                            <asp:Label ID="notesLabel" runat="server" Text='<%# Bind("notes") %>'></asp:Label>
                        </itemtemplate>
                        <edititemtemplate>
                            <asp:TextBox ID="notesText" runat="server" TextMode="MultiLine" Rows="7"
                                Text='<%# Bind("notes") %>'></asp:TextBox>
                        </edititemtemplate>
                    </telerik:GridTemplateColumn>
                    <telerik:GridTemplateColumn DataField="statusId" AllowFiltering ="false" HeaderText="Status"
                        UniqueName="statusId"  FilterControlWidth="40px" EditFormColumnIndex="0">
                        <ItemTemplate>
                            <asp:Label ID="sLabel" runat="server" Text='<%# Bind("status") %>'></asp:Label>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <telerik:RadComboBox ID="statusCombo" runat="server" DataSourceID="DS_Status"
                                DataTextField="description" DataValueField="id"
                                SelectedValue='<%# Eval("statusId")==DBNull.Value?"2":Eval("statusId") %>'>
                            </telerik:RadComboBox>
                        </EditItemTemplate>
                    </telerik:GridTemplateColumn>
                </Columns>          
            </MasterTableView>
            <ClientSettings>
                <ClientEvents OnPopUpShowing="PopUpShowing" />
            </ClientSettings>
        </telerik:RadGrid>
 
        <telerik:RadWindowManager ID="window" runat="server">
            <Windows>
                <telerik:RadWindow ID="pdfWindow" runat="server" Behaviors="Close" AutoSize="true" Modal="true">
                </telerik:RadWindow>
            </Windows>
        </telerik:RadWindowManager>
         <div style="margin: 0 auto; width:800px;">
        <iframe id="reportPdf" name="reportPdf" runat="server" width="800"
             height="700" visible="true" style="">
        </iframe>
    </div>
    <%-- This grid is for project tasks subtask--%>
        <telerik:RadGrid ID="subTaskRadGrid" AllowFilteringByColumn="false" runat="server" AllowPaging="true"
            PageSize="5" AutoGenerateColumns="false" ShowStatusBar="true" AllowSorting="true"
             OnUpdateCommand="subTaskRadGrid_UpdateCommand" OnItemCreated="subTaskRadGrid_ItemCreated"
            OnInsertCommand="subTaskRadGrid_InsertCommand" OnDeleteCommand="subTaskRadGrid_DeleteCommand"
            OnItemCommand="subTaskRadGrid_ItemCommand" Width="800px">
            <MasterTableView CommandItemDisplay="Top" DataKeyNames="id, taskId"
                EditMode="PopUp" EditFormSettings-PopUpSettings-Modal="true" PagerStyle-AlwaysVisible="true">
                <CommandItemSettings AddNewRecordText="Add Project Sub Tasks"
                     ShowAddNewRecordButton="true" ShowExportToCsvButton="true"
                    ShowRefreshButton="true" />          
                <Columns>
                    <telerik:GridEditCommandColumn Visible="true" ButtonType="ImageButton" HeaderStyle-Width="2%" HeaderText="Edit">
                    </telerik:GridEditCommandColumn>
                    <telerik:GridButtonColumn UniqueName="delete" CommandName="delete" ButtonType="ImageButton"
                         ImageUrl="~/images/cancel.png" HeaderText="Delete"
                        ConfirmText="Are you sure you want to delete this data?" HeaderStyle-Width="2%">
                    </telerik:GridButtonColumn>
                    <telerik:GridBoundColumn DataField="id" UniqueName="id" HeaderText="ID" ReadOnly="true" Visible="false">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="taskId" UniqueName="taskId"
                        HeaderText="taskId" ReadOnly="true" Visible="false">
                    </telerik:GridBoundColumn>               
                    <telerik:GridBoundColumn DataField="name" UniqueName="name" Visible="true" ReadOnly="false"
                         HeaderText="Sub Task Name">
                    </telerik:GridBoundColumn>                                      
                    <telerik:GridDateTimeColumn DataField="startDate" UniqueName="startDate" HeaderText="Start Date"
                         FilterControlWidth="100px" DataFormatString="{0:MMM dd, yyyy}">
                    </telerik:GridDateTimeColumn>
                    <telerik:GridDateTimeColumn DataField="endDate" UniqueName="endDate" HeaderText="End Date"
                         FilterControlWidth="100px" DataFormatString="{0:MMM dd, yyyy}" ReadOnly="true">
                    </telerik:GridDateTimeColumn>
                    <telerik:GridNumericColumn UniqueName="noOfDays" DataField="noOfDays" HeaderText="Duration" FilterControlWidth="25px">
                    </telerik:GridNumericColumn>                   
                    <telerik:GridNumericColumn UniqueName="gap" DataField="gap" HeaderText="Gap" FilterControlWidth="25px">
                    </telerik:GridNumericColumn>
                    <telerik:GridTemplateColumn EditFormColumnIndex="0" HeaderText="Held By" UniqueName="heldById"
                        HeaderStyle-Width="200px">
                        <ItemTemplate>
                            <asp:Label ID="heldLabel" runat="server" Text='<%# Bind("empName") %>'></asp:Label>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <telerik:RadComboBox ID="heldCombo" runat="server" DataSourceID="DS_Employee"
                                    DataTextField="name" DataValueField="id" SelectedValue='<%# Eval("heldById") %>'>
                            </telerik:RadComboBox>
                        </EditItemTemplate>
                    </telerik:GridTemplateColumn>               
                    <telerik:GridTemplateColumn DataField="notes" UniqueName="notes" HeaderText="Notes">
                        <itemtemplate>
                            <asp:Label ID="notesLabel" runat="server" Text='<%# Bind("notes") %>'></asp:Label>
                        </itemtemplate>
                        <edititemtemplate>
                            <asp:TextBox ID="notesText" runat="server" TextMode="MultiLine" Rows="7"
                                Text='<%# Bind("notes") %>'></asp:TextBox>
                        </edititemtemplate>
                    </telerik:GridTemplateColumn>
                    <telerik:GridTemplateColumn DataField="statusId" HeaderText="Status"
                        UniqueName="statusId"  FilterControlWidth="40px" EditFormColumnIndex="0">
                        <ItemTemplate>
                            <asp:Label ID="sLabel" runat="server" Text='<%# Bind("status") %>'></asp:Label>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <telerik:RadComboBox ID="statusCombo" runat="server" DataSourceID="DS_Status"
                                DataTextField="description" DataValueField="id"
                                SelectedValue='<%# Eval("statusId")==DBNull.Value?"2":Eval("statusId") %>'>
                            </telerik:RadComboBox>
                        </EditItemTemplate>
                    </telerik:GridTemplateColumn>
                </Columns>          
            </MasterTableView>
            <ClientSettings>
                <ClientEvents OnPopUpShowing="PopUpShowing" />
            </ClientSettings>
        </telerik:RadGrid>

0
Olga
Top achievements
Rank 1
answered on 13 Feb 2014, 09:18 PM
Back end code for the 3 rd and a 4th table at this page. Table number 3 which is called projectTasks has broken table view
#region Task
protected void fillProjectsTasks(int productRequestId)
{
    Task prodReq = new Task(sql);
    DataTable dt = prodReq.GetAllGrid(productRequestId);
    projectTasks.DataSource = dt;
    projectTasks.DataBind();
    RadGrid.Visible = true;
    projectTasks.Visible = true;
}
protected void projectTasks_PreRender(object sender, EventArgs e)
{
    bool userAuth = Roles.IsUserInRole(WebMatrix.WebData.WebSecurity.CurrentUserName, "Admin");
    foreach (GridDataItem item in projectTasks.Items)
    {
        if (!userAuth && (item.OwnerTableView.Name == "edit" || item.OwnerTableView.Name == "delete"))
        {
            item.OwnerTableView.CommandItemDisplay = GridCommandItemDisplay.None;
            item.OwnerTableView.Rebind();
        }
 
    }
}
 
protected void projectTasks_UpdateCommand(object sender, GridCommandEventArgs e)
{
    if (!Roles.IsUserInRole(WebSecurity.CurrentUserName, "Admin"))
    {
        RadAjaxManager1.ResponseScripts.Add(@"radalert('You are not authorise to Update.', 330,210);");
        return;
    }
    Task taskUpdate = new Task(sql);
    GridEditableItem updateItems = e.Item as GridEditableItem;
 
    int id = Convert.ToInt32(updateItems.OwnerTableView.DataKeyValues[updateItems.ItemIndex]["id"].ToString());
    string name = (updateItems["TaskName"].Controls[0] as TextBox).Text;
    int prodReqId = productRequestId;
    string desc = (updateItems["description"].Controls[0] as TextBox).Text;
    DateTime startDate = Convert.ToDateTime((updateItems["startDate"].Controls[0] as RadDatePicker).SelectedDate);
    DateTime modifiedDate = Convert.ToDateTime((updateItems["modifiedDate"].Controls[0] as RadDatePicker).SelectedDate);
    // Check if start day is on weekend, update to next coming Monday if so
    if (startDate.DayOfWeek == DayOfWeek.Saturday)
        startDate = startDate.AddDays(2);
    else if (startDate.DayOfWeek == DayOfWeek.Sunday)
        startDate = startDate.AddDays(1);
    ddlProductRequests prodReq = new ddlProductRequests(sql);
    bool completeTaskSchedule = prodReq.GetTaskScheduleComplete(productRequestId);
 
    string nDays = (updateItems["noOfDays"].Controls[0] as RadNumericTextBox).Text;
    string nGap = (updateItems["gap"].Controls[0] as RadNumericTextBox).Text;
    int numDays = 0;
    int gap = 0;
    if (int.TryParse(nDays, out numDays))
    {
        numDays = int.Parse(nDays);
    }
 
    if (int.TryParse(nGap, out gap))
    {
        gap = int.Parse(nGap);
    }
     
     
    #region get only weekdays and add it to duration
 
    DateTime endDate;
    if (numDays != 0)
    {
        endDate = AddBusinessDays(startDate, numDays);
    }
    else
        endDate = startDate;
 
    #endregion
 
    #region check if there are any dependent task
    RadComboBox dependTask = updateItems["DependTaskId"].Controls[0].FindControl("dependTaskIdCombo") as RadComboBox;
    int dependTaskId = 0;
    if (Convert.ToInt16(dependTask.SelectedValue) != 0)
        dependTaskId = Convert.ToInt32(dependTask.SelectedValue);
 
    DataRow taskDr = taskUpdate.GetDependTaskRow(dependTaskId);
    if (taskDr != null)
    {
        //compare to the end date of the previous task
        startDate = DateTime.Parse(taskDr["endDate"].ToString());
        //if startDate == Friday
        startDate = AddBusinessDays(startDate, (Convert.ToInt16(taskDr["gap"].ToString())+1));
        if (startDate.DayOfWeek == DayOfWeek.Saturday)
            startDate = startDate.AddDays(2);
        else if (startDate.DayOfWeek == DayOfWeek.Sunday)
            startDate = startDate.AddDays(1);
 
        if (numDays != 0)
        {
            endDate = AddBusinessDays(startDate, numDays);
        }
        else
            endDate = startDate;
 
        updateDependedTasks(id, startDate, endDate);
    }
    #endregion
 
    DataTable taskDt = taskUpdate.GetAllDependTask(id);
    DataRow taskDrActual = taskUpdate.GetDependTaskRow(id);        
 
    int heldContactId = Convert.ToInt32((updateItems["heldContactId"].Controls[0].FindControl("heldCombo") as RadComboBox).SelectedValue);
    string budget = (updateItems["budget"].Controls[0] as TextBox).Text;
    double budgetAmt = 0.0;
    double res = 0.0;
    if (Double.TryParse(budget, out res))
    {
        budgetAmt = Double.Parse(budget);
    }
    string notes = (updateItems["notes"].Controls[0].FindControl("notesText") as TextBox).Text;
    int statusId = Convert.ToInt32((updateItems["statusId"].Controls[0].FindControl("statusCombo") as RadComboBox).SelectedValue);
 
    int result = 0;
 
    if (modifiedDate.CompareTo(DateTime.MinValue) == 0)
    {
 
        result = taskUpdate.Update(id, prodReqId, name, desc, startDate, endDate, statusId, numDays,
                                    dependTaskId, gap, heldContactId, budgetAmt, notes);
    }
    else
    {
        result = taskUpdate.UpdateModifiedDate(id, productRequestId, name, desc, modifiedDate, endDate,
                                statusId, numDays, dependTaskId, gap, heldContactId, budgetAmt, notes);
    }
    if (result > 0)
    {
        taskUpdate.InsertTaskDependenceHistory(id, taskDrActual["taskName"].ToString(), taskDrActual["description"].ToString(),
                            DateTime.Parse(taskDrActual["startDate"].ToString()), DateTime.Parse(taskDrActual["endDate"].ToString()),
                            DateTime.Now, Convert.ToInt16(taskDrActual["heldContactid"].ToString()),
                            taskDrActual["notes"].ToString(), statusId);
         
        //new start date for dependable task
        // Set end date according to task's gap
        endDate = AddBusinessDays(endDate, gap + 1);
         
        updateDependedTasks(id, startDate, endDate);
    }
 
    if (completeTaskSchedule == true)
    {
        sendMail(productRequestId);
    }
    fillProjectsTasks(productRequestId);
}
protected void updateDependedTasks(int parentId, DateTime startDate, DateTime endDate)
{
    Task task = new Task(sql);
    DataTable dt = task.GetAllDependTask(parentId);
 
    if (dt.Rows.Count != 0)
    {
        for (int i = 0; i < dt.Rows.Count; i++)
        {
            int id = Convert.ToInt16(dt.Rows[i]["id"].ToString());
            DateTime sDate = endDate;
            DateTime nDate = endDate;
            int noOfDays = Convert.ToInt32(dt.Rows[i]["NoOfDays"].ToString());
            int g = Convert.ToInt32(dt.Rows[i]["gap"].ToString());
            #region get only weekdays and add it to duration
            nDate = AddBusinessDays(sDate, noOfDays);
 
            #endregion
            task.Update(id, sDate, nDate, noOfDays, g);      
            nDate = AddBusinessDays(nDate, g + 1);
            updateDependedTasks(id, sDate, nDate);           
        }
    }
     
}
protected void projectTasks_InsertCommand(object sender, GridCommandEventArgs e)
{
    if (!Roles.IsUserInRole(WebSecurity.CurrentUserName, "Admin"))
    {
        RadAjaxManager1.ResponseScripts.Add(@"radalert('You are not authorise to Insert.', 330,210);");
        return;
    }
    Task taskInsert = new Task(sql);
    GridEditableItem insertItems = e.Item as GridEditableItem;
 
    string name = (insertItems["TaskName"].Controls[0] as TextBox).Text;
    int prodReqId = productRequestId;
    string desc = (insertItems["description"].Controls[0] as TextBox).Text;
    DateTime startDate = Convert.ToDateTime((insertItems["startDate"].Controls[0] as RadDatePicker).SelectedDate);
    if (startDate.CompareTo(DateTime.MinValue) == 0)
    {
        startDate = DateTime.Now;
    }
    
    string nDays = (insertItems["noOfDays"].Controls[0] as RadNumericTextBox).Text;
    string nGap = (insertItems["gap"].Controls[0] as RadNumericTextBox).Text;
    int numDays = 0;
    int gap = 0;
 
 
 
    if (int.TryParse(nDays, out numDays))
    {
        numDays = int.Parse(nDays);
    }
 
    if (int.TryParse(nGap, out gap))
    {
        gap = int.Parse(nGap);
    }
 
    // Check if start day is on weekend, update to next coming Monday if so
    if (startDate.DayOfWeek == DayOfWeek.Saturday)
        startDate = startDate.AddDays(2);
    else if (startDate.DayOfWeek == DayOfWeek.Sunday)
        startDate = startDate.AddDays(1);
 
    #region check if there are any dependent task
    RadComboBox dependTask = insertItems["DependTaskId"].Controls[0].FindControl("dependTaskIdCombo") as RadComboBox;
    int dependTaskId = 0;
    if (Convert.ToInt16(dependTask.SelectedValue) != 0)
        dependTaskId = Convert.ToInt32(dependTask.SelectedValue);
 
    DataRow taskDr = taskInsert.GetDependTaskRow(dependTaskId);
    if (taskDr != null)
    {
        startDate = DateTime.Parse(taskDr["endDate"].ToString());
        //if startDate == Friday
        startDate = AddBusinessDays(startDate, (Convert.ToInt16(taskDr["gap"].ToString()) + 1));
        if (startDate.DayOfWeek == DayOfWeek.Saturday)
            startDate = startDate.AddDays(2);
        else if (startDate.DayOfWeek == DayOfWeek.Sunday)
            startDate = startDate.AddDays(1);
    }
    #endregion
    #region get only weekdays and add it to duration
 
    DateTime TempendDate = startDate.AddDays(numDays);
    DateTime endDate;
    if (numDays != 0)
    {
        endDate = AddBusinessDays(startDate, numDays);
         
    }
    else
        endDate = startDate;
 
    #endregion
 
    int heldContactId = Convert.ToInt32((insertItems["heldContactId"].Controls[0].FindControl("heldCombo") as RadComboBox).SelectedValue);
    string budget = (insertItems["budget"].Controls[0] as TextBox).Text;
    string notes = (insertItems["notes"].Controls[0].FindControl("notesText") as TextBox).Text;
    int statusId = Convert.ToInt32((insertItems["statusId"].Controls[0].FindControl("statusCombo") as RadComboBox).SelectedValue);
    double budgetAmt = 0.0;
    double res = 0.0;
    if (Double.TryParse(budget, out res))
    {
        budgetAmt = Double.Parse(budget);
    }
    int result = 0;
    if (name != "")
    {
        if( heldContactId != 0)
            result = taskInsert.Insert(prodReqId, name, desc, startDate, endDate, statusId, numDays, dependTaskId, gap, heldContactId, budgetAmt, notes);
        else
            ScriptManager.RegisterStartupScript(this.Page, typeof(System.Web.UI.Page), "ShowEmailPreview", "alert('Record can not be inserted, Held By cannot be empty');", true);
    }
    else
        ScriptManager.RegisterStartupScript(this.Page, typeof(System.Web.UI.Page), "ShowEmailPreview", "alert('Record can not be inserted, Task name');", true);
 
         
    if (result > 0)
    {
        if (dependTaskId != 0)
            taskInsert.InsertTaskDependence(result, dependTaskId, gap);
        ScriptManager.RegisterStartupScript(this.Page, typeof(System.Web.UI.Page), "ShowEmailPreview", "alert('Record has been inserted');", true);
    }
    else
        ScriptManager.RegisterStartupScript(this.Page, typeof(System.Web.UI.Page), "ShowEmailPreview", "alert('Record can not be inserted');", true);
 
    fillProjectsTasks(productRequestId);
    projectTasks.Visible = true;
    RadGrid.Visible = true;
 
}
protected void projectTasks_DeleteCommand(object sender, GridCommandEventArgs e)
{
    if (!Roles.IsUserInRole(WebSecurity.CurrentUserName, "Admin"))
    {
        RadAjaxManager1.ResponseScripts.Add(@"radalert('You are not authorise to Delete.', 330,210);");
        return;
    }
    Task taskDelete = new Task(sql);
    GridEditableItem deleteItem = e.Item as GridEditableItem;
 
    int id = Convert.ToInt32(deleteItem.OwnerTableView.DataKeyValues[deleteItem.ItemIndex]["id"].ToString());
 
    if (taskDelete.GetAllDependTask(id).Rows.Count > 0)
    {
        RadAjaxManager1.ResponseScripts.Add(@"radalert('Record can not be Deleted.Other Task are depended to this task.', 330,210);");
        return;
    }
    try
    {
        taskDelete.Delete(id);
        RadAjaxManager1.ResponseScripts.Add(@"radalert('Record has been Deleted', 330,210);");
    }
    catch (Exception ex)
    {
        RadAjaxManager1.ResponseScripts.Add(@"radalert('Record can not be Deleted', 330,210);");
    }
    fillProjectsTasks(productRequestId);
    projectTasks.Visible = true;
    RadGrid.Visible = true;
}
protected void projectTasks_ItemCommand(object sender, GridCommandEventArgs e)
{
    System.Console.WriteLine(e.CommandName);
    
    if (e.CommandName == RadGrid.RebindGridCommandName
        || e.CommandName == RadGrid.InitInsertCommandName
        || e.CommandName == RadGrid.EditAllCommandName
        || e.CommandName == RadGrid.DeleteCommandName
        || e.CommandName == RadGrid.CancelCommandName
        || e.CommandName == RadGrid.SortCommandName
        || e.CommandName == RadGrid.EditCommandName
        || e.CommandName == RadGrid.FilterCommandName
        || e.CommandName == RadGrid.PageCommandName
        || e.CommandName == "ChangePageSize"
        )
    {
        fillProjectsTasks(productRequestId);
        RadGrid.Visible = true;
        
    }
    else if (e.CommandName == "history")
    {
        projectContractGrid.Visible = false;
        GridDataItem item = e.Item as GridDataItem;
        int id = Convert.ToInt32(item.OwnerTableView.DataKeyValues[item.ItemIndex]["id"].ToString());
 
        taskId = id;
        fillProjectTasksHistory(taskId);
        projectTasks.MasterTableView.Items[item.ItemIndex].Selected = true;
        projectTasks.Visible = true;
        projectTasksHistoryRadGrid.Visible = true;
        subTaskRadGrid.Visible = false;
        RadGrid.Visible = true;
    }
    else if (e.CommandName == "subtask")
    {
        projectContractGrid.Visible = false;
        GridDataItem item = e.Item as GridDataItem;
        int id = Convert.ToInt32(item.OwnerTableView.DataKeyValues[item.ItemIndex]["id"].ToString());
 
        taskId = id;
        fillProjectSubTasks(taskId);
        projectTasks.MasterTableView.Items[item.ItemIndex].Selected = true;
        projectTasks.Visible = true;
        projectTasksHistoryRadGrid.Visible = false;
        subTaskRadGrid.Visible = true;
        RadGrid.Visible = true;
        
    }
    else if (e.CommandName == RadGrid.ExportToCsvCommandName)
        RadGrid.MasterTableView.ExportToCSV();
}
protected void projectTasks_ItemCreated(object sender, GridItemEventArgs e)
{
 
    if (e.Item is GridDataItem)
    {
        GridDataItem item = (GridDataItem)e.Item;
 
        if ((projectTasks.MasterTableView.GetColumn("subtask") as GridButtonColumn).Text.ToLower() == "subtask") // ListItemType.Item)
        {
            ccSubTask subTask = new ccSubTask(sql);
            GridDataItem deleteItem = e.Item as GridDataItem;
            int id = Convert.ToInt32(deleteItem.OwnerTableView.DataKeyValues[deleteItem.ItemIndex]["id"].ToString());
            if (subTask.GetAllGrid(id).Rows.Count > 0)
            {
                e.Item.CssClass = "TimeCss";
            }
        }
    }
 
    Task taskCreate = new Task(sql);
    GridEditableItem create = e.Item as GridEditableItem;
    if (e.Item is GridEditableItem && e.Item.IsInEditMode)
    {
        DataTable dt = taskCreate.GetOtherTask(productRequestId);
        if (e.Item is GridEditFormInsertItem || e.Item is GridDataInsertItem)
        {
            RadDatePicker modifiedDate = create["modifiedDate"].Controls[0] as RadDatePicker;
            modifiedDate.Visible = false;
            // insert item               
            if (dt.Rows.Count > 0)
            {
                RadComboBox dependTaskCombo = create["DependTaskId"].Controls[0].FindControl("dependTaskIdCombo") as RadComboBox;
                dependTaskCombo.Items.Insert(0, new RadComboBoxItem("None", "0"));
 
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    RadComboBoxItem rcbi = new RadComboBoxItem(dt.Rows[i]["taskName"].ToString(), dt.Rows[i]["id"].ToString());
                    dependTaskCombo.Items.Insert(i + 1, rcbi);
                }
 
                dependTaskCombo.DataBind();
 
                dependTaskCombo.SelectedIndex = 0;
            }
            else
            {
                RadComboBox dependTaskCombo = create["DependTaskId"].Controls[0].FindControl("dependTaskIdCombo") as RadComboBox;
                dependTaskCombo.Items.Insert(0, new RadComboBoxItem("None", "0"));
                dependTaskCombo.DataBind();
 
                dependTaskCombo.SelectedIndex = 0;
            }
        }
        else
        {
            ddlProductRequests prodReq = new ddlProductRequests(sql);
            if (prodReq.GetTaskScheduleComplete(productRequestId))
            {
                RadDatePicker startDate = create["startDate"].Controls[0] as RadDatePicker;
                //startDate.Enabled = false;
            }
            else
            {
                RadDatePicker modifiedDate = create["modifiedDate"].Controls[0] as RadDatePicker;
                modifiedDate.Enabled = false;
            }
            // edit item
            int id = Convert.ToInt32(create.OwnerTableView.DataKeyValues[create.ItemIndex]["id"].ToString());
            DataTable dtEdit = taskCreate.GetAllDependTask(id);
            if (dt.Rows.Count > 0)
            {
                RadComboBox dependTaskCombo = create["DependTaskId"].Controls[0].FindControl("dependTaskIdCombo") as RadComboBox;
 
                dependTaskCombo.Items.Insert(0, new RadComboBoxItem("None", "0"));
 
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    RadComboBoxItem rcbi = new RadComboBoxItem(dt.Rows[i]["taskName"].ToString(), dt.Rows[i]["id"].ToString());
                    dependTaskCombo.Items.Insert(i + 1, rcbi);
                }
                dependTaskCombo.DataBind();
 
                int result = taskCreate.GetDependTaskId(id);
                if (result != -1 && result != id && result != 0)
                    dependTaskCombo.SelectedValue = result.ToString();
                else
                    dependTaskCombo.SelectedIndex = 0;
            }
            else
            {
                RadComboBox dependTaskCombo = create["DependTaskId"].Controls[0].FindControl("dependTaskIdCombo") as RadComboBox;
                dependTaskCombo.Items.Insert(0, new RadComboBoxItem("None", "0"));
                dependTaskCombo.DataBind();
 
                dependTaskCombo.SelectedIndex = 0;
            }
        }
    }
 
}
#endregion
0
Olga
Top achievements
Rank 1
answered on 13 Feb 2014, 09:29 PM
code for the last table called subTaskRadGrid
#region Project Sub Tasks
protected void fillProjectSubTasks(int taskId)
{
    ccSubTask prSubTasks = new ccSubTask(sql);
    DataTable dt = prSubTasks.GetAllGrid(taskId);
    subTaskRadGrid.DataSource = dt;
    subTaskRadGrid.DataBind();
}
protected void subTaskRadGrid_UpdateCommand(object sender, GridCommandEventArgs e)
{
    ccSubTask subTask = new ccSubTask(sql);
    GridEditableItem updateItems = e.Item as GridEditableItem;
    int id = Convert.ToInt32(updateItems.OwnerTableView.DataKeyValues[updateItems.ItemIndex]["id"].ToString());
    int taskId = Convert.ToInt32(updateItems.OwnerTableView.DataKeyValues[updateItems.ItemIndex]["taskId"].ToString());
 
    DataRow dr = subTask.OriginalTaskDate(taskId);
    DateTime orginalStartDate = DateTime.Parse(dr["startDate"].ToString());
    DateTime orginalEndDate = DateTime.Parse(dr["endDate"].ToString());
 
    string name = (updateItems["name"].Controls[0] as TextBox).Text;
    DateTime startDate = Convert.ToDateTime((updateItems["startDate"].Controls[0] as RadDatePicker).SelectedDate);
    string nDays = (updateItems["noOfDays"].Controls[0] as RadNumericTextBox).Text;
    string nGap = (updateItems["gap"].Controls[0] as RadNumericTextBox).Text;
    int numDays = 0;
    int gap = 0;
 
    if ((startDate.CompareTo(DateTime.MinValue) == 0))
    {
        startDate = orginalStartDate;
    }
 
    if (startDate.CompareTo(orginalStartDate) < 0)
        startDate = orginalStartDate;
    else if (startDate.CompareTo(orginalEndDate) > 0)
        startDate = orginalStartDate;
 
    if (int.TryParse(nDays, out numDays))
    {
        numDays = int.Parse(nDays);
    }
 
    if (int.TryParse(nGap, out gap))
    {
        gap = int.Parse(nGap);
    }
 
    int heldContactId = Convert.ToInt32((updateItems["heldById"].Controls[0].FindControl("heldCombo") as RadComboBox).SelectedValue);
    string notes = (updateItems["notes"].Controls[0].FindControl("notesText") as TextBox).Text;
    int statusId = Convert.ToInt32((updateItems["statusId"].Controls[0].FindControl("statusCombo") as RadComboBox).SelectedValue);
 
    #region get only weekdays and add it to duration
 
    DateTime TempendDate = startDate.AddDays(numDays);
    DateTime endDate;
    if (numDays != 0)
    {
        endDate = AddBusinessDays(startDate, numDays);
    }
    else
        endDate = startDate;
 
    if (endDate.CompareTo(orginalEndDate) > 0) // check if the end date is greater than the end date of the parent end date
    {
        endDate = orginalEndDate;     // the end date of the parent task
    }
 
    #endregion
    if (subTask.Update(id, taskId, name, startDate, endDate, statusId, numDays, gap, heldContactId, notes) > 0)
    {
        RadAjaxManager1.ResponseScripts.Add(@"radalert('Record has been Updated', 330,210);");
    }
    else
        RadAjaxManager1.ResponseScripts.Add(@"radalert('Record can not be Updated', 330,210);");
 
    fillProjectSubTasks(taskId);
 
}
protected void subTaskRadGrid_ItemCreated(object sender, GridItemEventArgs e)
{
 
}
protected void subTaskRadGrid_DeleteCommand(object sender, GridCommandEventArgs e)
{
    ccSubTask subTask = new ccSubTask(sql);
    GridEditableItem editItems = e.Item as GridEditableItem;
    int id = Convert.ToInt32(editItems.OwnerTableView.DataKeyValues[editItems.ItemIndex]["id"].ToString());
 
    try
    {
        subTask.Delete(id);
    }
    catch (Exception ex)
    {
    }
    fillProjectSubTasks(taskId);
}
protected void subTaskRadGrid_InsertCommand(object sender, GridCommandEventArgs e)
{
    ccSubTask subTask = new ccSubTask(sql);
    GridEditableItem insertItems = e.Item as GridEditableItem;
    DataRow dr = subTask.OriginalTaskDate(taskId);
    DateTime orginalStartDate = DateTime.Parse(dr["startDate"].ToString());
    DateTime orginalEndDate = DateTime.Parse(dr["endDate"].ToString());
 
    string name = (insertItems["name"].Controls[0] as TextBox).Text;
    DateTime startDate = Convert.ToDateTime((insertItems["startDate"].Controls[0] as RadDatePicker).SelectedDate);
 
    if (startDate.DayOfWeek == DayOfWeek.Saturday)
        startDate = startDate.AddDays(2);
    else if (startDate.DayOfWeek == DayOfWeek.Sunday)
        startDate = startDate.AddDays(1);
 
    string nDays = (insertItems["noOfDays"].Controls[0] as RadNumericTextBox).Text;
    string nGap = (insertItems["gap"].Controls[0] as RadNumericTextBox).Text;
    int numDays = 1;
    int gap = 0;
 
    if ((startDate.CompareTo(DateTime.MinValue) == 0))
    {
        startDate = orginalStartDate;
    }
 
    //compare the start date with start date of the parent task
    if (startDate.CompareTo(orginalTaskStartDate) < 0)
        startDate = orginalStartDate;
    else if (startDate.CompareTo(orginalTaskEndDate) > 0)
        startDate = orginalStartDate;
 
 
    if (int.TryParse(nDays, out numDays))
    {
        numDays = int.Parse(nDays);
    }
 
    if (int.TryParse(nGap, out gap))
    {
        gap = int.Parse(nGap);
    }
 
    int heldContactId = Convert.ToInt32((insertItems["heldById"].Controls[0].FindControl("heldCombo") as RadComboBox).SelectedValue);
    string notes = (insertItems["notes"].Controls[0].FindControl("notesText") as TextBox).Text;
    int statusId = Convert.ToInt32((insertItems["statusId"].Controls[0].FindControl("statusCombo") as RadComboBox).SelectedValue);
 
    #region get only weekdays and add it to duration
 
    DateTime endDate;
    if (numDays != 0)
    {
        endDate = AddBusinessDays(startDate, numDays);
    }
    else
        endDate = startDate;
 
    if (endDate.CompareTo(orginalTaskEndDate) > 0) // check if the end date is greater than the end date of the parent end date
    {
        endDate = orginalEndDate;     // the end date of the parent task
    }
 
    #endregion
 
 
    //if (subTask.Insert(taskId, name, startDate, endDate, statusId, numDays, gap, heldContactId, notes) > 0)
    //{
    //    RadAjaxManager1.ResponseScripts.Add(@"radalert('Record has been Inserted', 330,210);");
    //}
    //else
    //    RadAjaxManager1.ResponseScripts.Add(@"radalert('Record can not be Inserted', 330,210);");
 
    int result = 0;
    if (name != "")
    {
        if(heldContactId != 0)
            result = subTask.Insert(taskId, name, startDate, endDate, statusId, numDays, gap, heldContactId, notes);
    }
    else
        ScriptManager.RegisterStartupScript(this.Page, typeof(System.Web.UI.Page), "ShowEmailPreview", "alert('Record can not be inserted, Task name or Held By cannot be empty');", true);
 
    if (result > 0)
         ScriptManager.RegisterStartupScript(this.Page, typeof(System.Web.UI.Page), "ShowEmailPreview", "alert('Record has been inserted');", true);
    else
        ScriptManager.RegisterStartupScript(this.Page, typeof(System.Web.UI.Page), "ShowEmailPreview", "alert('Record can not be inserted, Task name or Held By cannot be empty');", true);
 
 
 
    fillProjectSubTasks(taskId);
}
protected void subTaskRadGrid_ItemCommand(object sender, GridCommandEventArgs e)
{
    if (e.CommandName == RadGrid.RebindGridCommandName
        || e.CommandName == RadGrid.InitInsertCommandName
        || e.CommandName == RadGrid.EditAllCommandName
        || e.CommandName == RadGrid.DeleteCommandName
        || e.CommandName == RadGrid.CancelCommandName
        || e.CommandName == RadGrid.SortCommandName
        || e.CommandName == RadGrid.EditCommandName
        || e.CommandName == RadGrid.FilterCommandName
        || e.CommandName == RadGrid.PageCommandName)
    {
        fillProjectSubTasks(taskId);
    }
    //else ()
 
    if (e.CommandName == RadGrid.ExportToCsvCommandName)
        RadGrid.MasterTableView.ExportToCSV();
}
#endregion
protected void RadWindow1_Disposed(object sender, EventArgs e)
{
    RadAjaxManager1.ResponseScripts.Add(@"document.location.reload(true)");
}
 
protected void contCombo_ItemDataBound(object sender, RadComboBoxItemEventArgs e)
{
 
    //e.Item.Checked=true;// = string.Concat(e.Item.Text.ToLower().Split(' ')[0]);
 
}
protected void contCombo_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
{
 
    //e.Item.Checked = true;
}
0
Olga
Top achievements
Rank 1
answered on 13 Feb 2014, 10:41 PM
I fixed, issue were at this code
        if (e.Item is GridDataItem)
        {
            GridDataItem item = (GridDataItem)e.Item;
 
            if ((projectTasks.MasterTableView.GetColumn("subtask") as GridButtonColumn).Text.ToLower() == "subtask") // ListItemType.Item)
            {
                ccSubTask subTask = new ccSubTask(sql);
                GridDataItem deleteItem = e.Item as GridDataItem;
                int id = Convert.ToInt32(deleteItem.OwnerTableView.DataKeyValues[deleteItem.ItemIndex]["id"].ToString());
                if (subTask.GetAllGrid(id).Rows.Count > 0)
                {
                    e.Item.CssClass = "TimeCss";
                }
            }
        }
 
 
and code from front side
 
    <style>
        TimeCss {
            color: red !important;
        }
 
    </style>

It is probably conflicted with css for the page, any way I comment it and it is working fine! 
Tags
General Discussions
Asked by
Olga
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Olga
Top achievements
Rank 1
Share this question
or