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
30
WebHierarchicalDataGrid - Add Child Row while populating foreign key from Primary key of parent row.
posted

Hello there,

I might be missing something very simple. However, when using the Add Child row function is there a simple way of adding the Primary key (or relationship reference) to a foreign key.

The senario is.

Two SQL tables.

UserData

UserID, UserFirstName, UserLastName, UserCurrent.........

SystemData

SystemID, SystemName, SystemUserName, SystemCurrent, SystemUserID......

So UserID references the SystemUserID as a parent child relationship.

The WebHierarchicalDataGrid seems to be an excellent choice in a easy to use user input control. I have been able to add child rows to the parent rows manually, however I really need to have this automated.

As I said, I am sure this is a really simple question, but the answer eluides me and is driving me crazy.

Many thanks,

Steven.

P.S: If you could include some samples that would be awesome. Cheers.

  • 30
    Verified Answer
    posted

    I have managed to code a resolution for this based on Java and VB.

    Using the mouse over event handler the following code populates a hidden field

    ------------------8<----------------------------------------

            function WebHierarchicalDataGrid1_ContainerGrid_MouseOver(sender, eventArgs) {

                ///<summary>

                ///

                ///</summary>

                ///<param name="sender" type="Infragistics.Web.UI.WebHierarchicalDataGrid"></param>

                ///<param name="eventArgs" type="Infragistics.Web.UI.ItemEventArgs"></param>

     

                if (eventArgs.get_type() == "row") {

     

                    var grid = ig_controls["WebHierarchicalDataGrid1"];

                    var containerGrid = grid.get_gridView();

                    var i = eventArgs.get_item().get_index();

                    document.getElementById('TextBox1').value = containerGrid.get_rows().get_row(i).get_cellByColumnKey("UserID").get_text();

     

                }

     

            }

    ------------------>8----------------------------------------

    I then modify the inserting subroutine of the WebHierachicalDataSource to insert the value from the hidden text box field directly into the insert statement of the Datasource provider for the child row.

    ------------------8<-------------------------------------------

    Private Sub WebHierarchicalDataSource1_Inserting(ByVal sender As Object, ByVal e As Infragistics.Web.UI.DataSourceControls.WebHierarchicalDataSourceInsertEventArgs) Handles WebHierarchicalDataSource1.Inserting

     

            SystemData.InsertCommand = "INSERT INTO [TblSystemRegister] ([SystemPassword], [SystemUserName], [SystemName], [SystemStartDate], [SystemEndDate], [SystemLicenseUsage], [SystemDeviceID], [SystemSource], [SystemInvestorType], [SystemCurrent], [SystemAccess], [SystemUserID], [SystemDisplay], [SystemDisplayType], [SystemUnitOfCount], [SystemRoyalty]) VALUES (@SystemPassword, @SystemUserName, @SystemName, @SystemStartDate, @SystemEndDate, @SystemLicenseUsage, @SystemDeviceID, @SystemSource, @SystemInvestorType, 'true', @SystemAccess, '" & TextBox1.Text & "' , @SystemDisplay, @SystemDisplayType, @SystemUnitOfCount, @SystemRoyalty)"

     

        End Sub

    ------------------>8------------------------------

      Its a bit of a hack resolution, but for my testing development it works very well.