Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
125
Web Hierarchical Child Row Delete
posted

        <ig:WebHierarchicalDataGrid ID="WebDataGrid1" runat="server"
            AutoGenerateBands="False" AutoGenerateColumns="False" DataKeyFields="Id"
            DataMember="dsDivisions_DefaultView"
            Height="380px" Key="dsDivisions_DefaultView" Width="100%" StyleSetName="LucidDream">
            <Columns>
                <ig:bounddatafield datafieldname="Name" key="Name"><header text="Name"></header></ig:bounddatafield>
                <ig:bounddatafield datafieldname="Name1" key="Name1"><header text="Name1"></header></ig:bounddatafield>
            </Columns>
            <Bands>
                <ig:band autogeneratecolumns="False" DataKeyFields="Id" ShowHeader="true" datamember="dsAssessments_DefaultView" OnRowsDeleting="RowDeleting" key="dsAssessments_DefaultView">
                    <Columns>
                        <ig:BoundDataField DataFieldName="Id" Key="Id" Hidden="true"><Header Text="Id"></Header></ig:BoundDataField>
                        <ig:bounddatafield datafieldname="SurveyName" key="SurveyName"><header text="Survey Name"></header></ig:bounddatafield>
                        <ig:bounddatafield datafieldname="EmployeeName" key="EmployeeName"><header text="Employee Name"></header></ig:bounddatafield>
                        <ig:bounddatafield datafieldname="DateCreated" key="DateCreated"><header text="Date Created"></header></ig:bounddatafield>
                        <ig:bounddatafield datafieldname="DateCompleted" key="DateCompleted"><header text="Date Completed"></header></ig:bounddatafield>
                        <ig:bounddatafield datafieldname="Total" key="Total" Width="100px"><header text="Total Completed"></header></ig:bounddatafield>
                        <ig:bounddatafield datafieldname="ClientExternal" key="ClientExternal" Width="100px"><header text="Client External Completed"></header></ig:bounddatafield>
                        <ig:bounddatafield datafieldname="ClientInternal" key="ClientInternal" Width="100px"><header text="Client Internal Completed"></header></ig:bounddatafield>
                        <ig:bounddatafield datafieldname="Team" key="Team" Width="100px"><header text="Team Completed"></header></ig:bounddatafield>
                        <ig:bounddatafield datafieldname="Peer" key="Peer" Width="100px"><header text="Peer Completed"></header></ig:bounddatafield>
                        <ig:bounddatafield datafieldname="Leader" key="Leader" Width="100px"><header text="Leader Completed"></header></ig:bounddatafield>
                        <ig:TemplateDataField Width="50px" Key="Edit" Header-Text="Edit">
                            <ItemTemplate>
                                <img alt="edit" name="btnEdit" title="Edit Assessment" onclick="ClickEditButton(this.parentElement.parentElement)" ID="btnEdit" src="../../Images/Icons/16/pencil_16.gif" runat="server" />
                            </ItemTemplate>
                        </ig:TemplateDataField>
                        <ig:TemplateDataField Width="50px" Key="Mail" Header-Text="Mail">
                            <ItemTemplate>
                                <img alt="email" title="Send emails to Assessees" name="btnMail" onclick="ClickMailButton(this.parentElement.parentElement)" ID="btnMail" src="../../Images/OutlookMail/mail.gif" runat="server" />
                            </ItemTemplate>
                        </ig:TemplateDataField>
                        <ig:TemplateDataField Width="50px" Key="Delete" Header-Text="Delete">
                            <ItemTemplate>
                                <img alt="delete" title="Delete Assessment" name="btnDel"  ID="btnDel" src="~/Images/ECS/DeleteSmall.gif" runat="server" onclick="DeleteChildRow()" />
                            </ItemTemplate>
                        </ig:TemplateDataField>
                    </Columns>
                    <Behaviors>
                        <ig:EditingCore AutoCRUD="false" EnableInheritance="true">
                        <Behaviors>
                        <ig:RowDeleting Enabled="true" />
                        </Behaviors>
                        </ig:EditingCore>
                    </Behaviors>
                </ig:band>
            </Bands>
            <Behaviors>
                <ig:VirtualScrolling ScrollingMode="Deferred"></ig:VirtualScrolling>
                <ig:ColumnResizing></ig:ColumnResizing>
                <ig:Sorting></ig:Sorting>
                <ig:Selection CellClickAction="Row" RowSelectType="Single"></ig:Selection>
                <ig:activation></ig:activation>
            </Behaviors>
        </ig:WebHierarchicalDataGrid>

        <ig:WebHierarchicalDataSource ID="WebHierarchicalDataSource1" runat="server">
            <DataRelations>
                <ig:DataRelation ChildDataViewID="dsAssessments_DefaultView"
                    ChildColumns="DivisionId" ParentDataViewID="dsDivisions_DefaultView"
                    ParentColumns="Id"></ig:DataRelation>
            </DataRelations>
            <DataViews>
                <ig:dataview id="dsDivisions_DefaultView"
                    datamember="DefaultView" datasourceid="dsDivisions"></ig:dataview>
                <ig:dataview id="dsAssessments_DefaultView"
                    datamember="DefaultView" datasourceid="dsAssessments"></ig:dataview>
            </DataViews>
        </ig:WebHierarchicalDataSource>
        <asp:SqlDataSource ID="dsAssessments"  runat="server" SelectCommandType="StoredProcedure"
            SelectCommand="[ECS].[GetAssessments]" DeleteCommand="[ECS].[Assessment_Delete]" DeleteCommandType="StoredProcedure"
            ConnectionString="<%$ ConnectionStrings:cnEvalexI %>">
            <DeleteParameters>
                <asp:Parameter Name="Id" DbType="Int32" />
            </DeleteParameters>
        </asp:SqlDataSource>
        <asp:SqlDataSource ID="dsDivisions"  runat="server" SelectCommandType="StoredProcedure"
            SelectCommand="[dbo].[Division_GetAllDivisions]"
            ConnectionString="<%$ ConnectionStrings:cnEvalexI %>">
            <SelectParameters>
                <asp:Parameter Name="CompanyId" Type="Int32" DefaultValue="0" />
            </SelectParameters>
        </asp:SqlDataSource>
        <script language="javascript" type="text/javascript">
            function DeleteChildRow() {
                var grid = $find('WebDataGrid1');
                var gridRows = grid.get_gridView().get_rows();
                var selectedRows;
                var row;
                var childGrid;
                for (var j = 0; j < gridRows.get_length(); j++) {
                    row = gridRows.get_row(j);

                    childGrid = row.get_rowIslands()[0];
                    childGridRows = childGrid.get_rows();
                    selectedRows = childGrid.get_behaviors().get_selection().get_selectedRows();

                    if (selectedRows.get_length() > 0) {


                        for (var i = selectedRows.get_length() - 1; i >= 0; i--) {

                            row = selectedRows.getItem(i);
                            childGridRows.remove(row);
                        }
                        // Single Select allowed
                        break;
                    }
                }
            }
       
        </script>