RadGrid Hierarchy problem (parent table not deleting nor updatin

9 posts, 1 answers
  1. Cholo
    Cholo avatar
    14 posts
    Member since:
    Mar 2016

    Posted 22 Mar Link to this post

    (question from a noob)

    I'm stuck, and i couldn't find my answer. So here it goes:

    I made a grid with an hierarchy (w/ one detail or child table). I utilized the auto update, add and delete options but it only works with the child table. The parent one doesn't seem to update nor delete any record at all.

    Can't seem to follow the demo too.Any direction is appreciated!

    <asp:Panel ID="Panel1" runat="server">
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="RadGrid1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" />
        <telerik:RadFormDecorator RenderMode="Lightweight" runat="server" DecorationZoneID="demo" EnableRoundedCorners="false" DecoratedControls="All" />
        <div id="demo" class="demo-container no-bg">
            <telerik:RadGrid ID="RadGrid1" runat="server" DataSourceID="SqlDataSource1" GroupPanelPosition="Top" AllowAutomaticDeletes="True" AllowAutomaticInserts="True" AllowAutomaticUpdates="True" AllowPaging="True" Skin="Black" GroupingSettings-GroupContinuesFormatString=" Group continues on the next page." MasterTableView-CommandItemDisplay="Top" EditItemStyle-HorizontalAlign="Right" MasterTableView-EditMode="EditForms" MasterTableView-EnableColumnsViewState="True" GroupingSettings-GroupSplitDisplayFormat="Showing {0} of {1} items." AutoGenerateDeleteColumn="True" AutoGenerateEditColumn="True">
                <MasterTableView DataKeyNames="JobFunction" DataSourceID="SqlDataSource1" AutoGenerateColumns="False">
     
                    <DetailTables>
                        <telerik:GridTableView runat="server" DataKeyNames="EmployeeIndex" DataSourceID="SqlDataSource2" CommandItemDisplay="Top">
                            <ParentTableRelation>
                                <telerik:GridRelationFields MasterKeyField="JobFunction" DetailKeyField="JobFunction"></telerik:GridRelationFields>
                            </ParentTableRelation>
     
                            <EditFormSettings>
                                <EditColumn UniqueName="EditCommandColumn1" FilterControlAltText="Filter EditCommandColumn1 column"></EditColumn>
                            </EditFormSettings>
                        </telerik:GridTableView>
                    </DetailTables>
     
                    <CommandItemSettings AddNewRecordText="Add New Function" ShowExportToExcelButton="True" ShowExportToPdfButton="True"></CommandItemSettings>
                    <Columns>
                        <telerik:GridClientDeleteColumn FilterControlAltText="Filter column column" UniqueName="column"></telerik:GridClientDeleteColumn>
                        <telerik:GridEditCommandColumn></telerik:GridEditCommandColumn>
                        <telerik:GridBoundColumn DataField="JobFunctionIndex" ReadOnly="True" HeaderText="JobFunctionIndex" SortExpression="JobFunctionIndex" UniqueName="JobFunctionIndex" DataType="System.Int32" FilterControlAltText="Filter JobFunctionIndex column"></telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="JobFunction" HeaderText="JobFunction" SortExpression="JobFunction" UniqueName="JobFunction" FilterControlAltText="Filter JobFunction column"></telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="Description" HeaderText="Description" SortExpression="Description" UniqueName="Description" FilterControlAltText="Filter Description column"></telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="Profile1" HeaderText="Profile1" SortExpression="Profile1" UniqueName="Profile1" FilterControlAltText="Filter Profile1 column"></telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="Profile2" HeaderText="Profile2" SortExpression="Profile2" UniqueName="Profile2" FilterControlAltText="Filter Profile2 column"></telerik:GridBoundColumn>
                    </Columns>
                </MasterTableView>
            </telerik:RadGrid>
     
            <asp:SqlDataSource runat="server" ID="SqlDataSource1" ConnectionString='<%$ ConnectionStrings:SiteSqlServer %>' SelectCommand="SELECT * FROM [Bak-JobFunction]" DeleteCommand="DELETE FROM [Bak-JobFunction] WHERE [JobFunctionIndex] = @JobFunctionIndex" InsertCommand="INSERT INTO [Bak-JobFunction] ([JobFunction], [Description], [Profile1], [Profile2]) VALUES (@JobFunction, @Description, @Profile1, @Profile2)" UpdateCommand="UPDATE [Bak-JobFunction] SET [JobFunction] = @JobFunction, [Description] = @Description, [Profile1] = @Profile1, [Profile2] = @Profile2 WHERE [JobFunctionIndex] = @JobFunctionIndex">
                <DeleteParameters>
                    <asp:Parameter Name="JobFunctionIndex" Type="Int32"></asp:Parameter>
                </DeleteParameters>
                <InsertParameters>
                    <asp:Parameter Name="JobFunction" Type="String"></asp:Parameter>
                    <asp:Parameter Name="Description" Type="String"></asp:Parameter>
                    <asp:Parameter Name="Profile1" Type="String"></asp:Parameter>
                    <asp:Parameter Name="Profile2" Type="String"></asp:Parameter>
                </InsertParameters>
                <UpdateParameters>
                    <asp:Parameter Name="JobFunction" Type="String"></asp:Parameter>
                    <asp:Parameter Name="Description" Type="String"></asp:Parameter>
                    <asp:Parameter Name="Profile1" Type="String"></asp:Parameter>
                    <asp:Parameter Name="Profile2" Type="String"></asp:Parameter>
                    <asp:Parameter Name="JobFunctionIndex" Type="Int32"></asp:Parameter>
                </UpdateParameters>
            </asp:SqlDataSource>
        </div>
    </asp:Panel>
     
     
    <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString='<%$ ConnectionStrings:SiteSqlServer %>' DeleteCommand="DELETE FROM [Bak-Employee] WHERE [EmployeeIndex] = @EmployeeIndex" InsertCommand="INSERT INTO [Bak-Employee] ([NameFirst], [NameMiddle], [JobFunction]) VALUES (@NameFirst, @NameMiddle, @JobFunction)" SelectCommand="SELECT [EmployeeIndex], [NameFirst], [NameMiddle], [JobFunction] FROM [Bak-Employee] WHERE ([JobFunction] = @JobFunction)" UpdateCommand="UPDATE [Bak-Employee] SET [NameFirst] = @NameFirst, [NameMiddle] = @NameMiddle, [JobFunction] = @JobFunction WHERE [EmployeeIndex] = @EmployeeIndex">
        <DeleteParameters>
            <asp:Parameter Name="EmployeeIndex" Type="Int32"></asp:Parameter>
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="NameFirst" Type="String"></asp:Parameter>
            <asp:Parameter Name="NameMiddle" Type="String"></asp:Parameter>
            <asp:Parameter Name="JobFunction" Type="String"></asp:Parameter>
        </InsertParameters>
        <SelectParameters>
            <asp:SessionParameter SessionField="JobFunction" DefaultValue="JobFunction" Name="JobFunction" Type="String"></asp:SessionParameter>
        </SelectParameters>
        <UpdateParameters>
            <asp:Parameter Name="NameFirst" Type="String"></asp:Parameter>
            <asp:Parameter Name="NameMiddle" Type="String"></asp:Parameter>
            <asp:Parameter Name="JobFunction" Type="String"></asp:Parameter>
            <asp:Parameter Name="EmployeeIndex" Type="Int32"></asp:Parameter>
        </UpdateParameters>
    </asp:SqlDataSource>

  2. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 25 Mar Link to this post

    Hi Cholo,

    I tried to replicate the described issue on my end but to no avail. Find my test project attached and see what the difference in your case is.

    Regards,
    Maria Ilieva
    Telerik
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Cholo
    Cholo avatar
    14 posts
    Member since:
    Mar 2016

    Posted 25 Mar in reply to Maria Ilieva Link to this post

    Hey Maria, Appreciate the help. I've added the following in my RadGrid tag and used the functions from C but it's still not updating nor deleting any entries from my SQL table.

    OnFilterCheckListItemsRequested="RadGrid1_FilterCheckListItemsRequested"
    OnColumnCreated="grdMultiNAV_ColumnCreated"

  5. Cholo
    Cholo avatar
    14 posts
    Member since:
    Mar 2016

    Posted 29 Mar Link to this post

    I got it working. For reference, here's what i did. I followed the 3 level heirarchy demo. And added the following within the RadGrid tag

         
    <telerik:RadGrid ID="RadGrid1" runat="server" CellSpacing="0" DataSourceID="SqlDataSource1" GridLines="Both" GroupPanelPosition="Top" AllowPaging="True" AllowFilteringByColumn="True" AllowSorting="True" OnItemUpdated="RadGrid1_ItemUpdated" OnItemDeleted="RadGrid1_ItemDeleted"
        OnItemInserted="RadGrid1_ItemInserted" OnInsertCommand="RadGrid1_InsertCommand"
        OnItemCreated="RadGrid1_ItemCreated" Skin="Windows7">

    Then, i followed the same code in the demo. I just took out the code referencing to an additional detail table and swapped it with my own table names. 

     

    It's currently working. I just couldn't figure out how to make the text boxes have a white backround in edit mode. Do i need to add another method?

  6. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 30 Mar Link to this post

    Hello Cholo,

    I'm not sure what you mean by making the editing textbox background to be white. This is actually the default behvaiour that can be seen in the demo below:
    http://demos.telerik.com/aspnet-ajax/grid/examples/data-editing/insert-update-delete-hierarchy/defaultcs.aspx?skin=Windows7

    What is the background in your case?

    Regards,
    Maria Ilieva
    Telerik
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
  7. Cholo
    Cholo avatar
    14 posts
    Member since:
    Mar 2016

    Posted 06 Apr in reply to Maria Ilieva Link to this post

    Here's what it looks like from my end

    http://imgur.com/hRFX6CG

  8. Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    1793 posts

    Posted 11 Apr Link to this post

    Hi Cholo,

    From the screenshot It seems that you are using the Default skin for the RadGrid, but the input elements for the Default skin and RadFormDecorator on the page should be set to white background (as in the online demo that Maria have mentioned in her last post).

    Could you please inspect the input elements with the gray background in your browser and see if are not applying any custom CSS to them.

    Looking forward to your reply.


    Regards,
    Konstantin Dikov
    Telerik
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
  9. Cholo
    Cholo avatar
    14 posts
    Member since:
    Mar 2016

    Posted 12 Apr in reply to Konstantin Dikov Link to this post

    I don't know what to make of it. But, if i understand it correctly, it appears to be taking a CSS from the CMS we have it on. If i got it wrong, please let me know.

    I copied what i saw in the element when i checked it out

     

    <input name="dnn$ctr14159$ShiftManagement$RadPanelBar1$i4$i0$RadGrid1$ctl00$ctl05$TB_Shift" type="text" value="A:06 -IN        " id="dnn_ctr14159_ShiftManagement_RadPanelBar1_i4_i0_RadGrid1_ctl00_ctl05_TB_Shift" style="cursor: auto; background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAABHklEQVQ4EaVTO26DQBD1ohQWaS2lg9JybZ+AK7hNwx2oIoVf4UPQ0Lj1FdKktevIpel8AKNUkDcWMxpgSaIEaTVv3sx7uztiTdu2s/98DywOw3Dued4Who/M2aIx5lZV1aEsy0+qiwHELyi+Ytl0PQ69SxAxkWIA4RMRTdNsKE59juMcuZd6xIAFeZ6fGCdJ8kY4y7KAuTRNGd7jyEBXsdOPE3a0QGPsniOnnYMO67LgSQN9T41F2QGrQRRFCwyzoIF2qyBuKKbcOgPXdVeY9rMWgNsjf9ccYesJhk3f5dYT1HX9gR0LLQR30TnjkUEcx2uIuS4RnI+aj6sJR0AM8AaumPaM/rRehyWhXqbFAA9kh3/8/NvHxAYGAsZ/il8IalkCLBfNVAAAAABJRU5ErkJggg=="); background-attachment: scroll; background-size: 16px 18px; background-position: 98% 50%; background-repeat: no-repeat;">

  10. Answer
    Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    1793 posts

    Posted 14 Apr Link to this post

    Hi Cholo,

    I see no class names in the input element in question, so no styles from RadGrid are used in the styling of that element, so you need to revise the loaded CSS files and modify them accordingly.

    As a workaround you could try to override the background of the input elements with the following:
    .RadGrid .rgEditForm input {
        background: #fff!important;
    }


    Best Regards,
    Konstantin Dikov
    Telerik
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017