Ticket Q218913
Visible to All Users

Custom edit form for master detail row

created 16 years ago

hi,
the ASPxGridView is indeed a powerful grid component. I was trying out the master detail concept of the grid, it seems i can only edit/add new/delete record of master or detail grid individually.
example:
user create a new master record. when it comes to the detail record user will need to expand from the master record and add them individually.
i am thinking if there's a solution where the user is able to just click on a add new/edit record button from the master grid and there will be a custom edit form where the user can input the master record followed by as many detail record of that master record
everything (add new/edit/delete) to be done on one particular edit form from the master grid is what i hope to achieve
but to view the records, as usual master-detail concept is perfect :)
i do hope you understand my situation
thanks a lot for helping,
Vian

Comments (2)
DevExpress Support Team 16 years ago

    Hello Vian,
    Thank you for your question. A master ASPxGridView knows nothing about the detail grid, its columns and data source. That's why this feature cannot be built in the ASPxGridView. However, you can implement such an edit form yourself. The Editing in a new window example may help you.
    Thanks,
    Nick
    --------------------
    Check if Search Engine is able to answer questions faster than I do!

      hi Nick,
      Thanks for the direction. I've tried http://www.devexpress.com/example=E65
      Is it possible to call grid.DataBind() right after EditForm.aspx is close, window.close()?
      Thanks,
      Vian

      Answers

      created 16 years ago

      Hi Vian,
      You can do this by defining a new client-side function in the main window and calling it when the Update button on the Edit form is clicked:

      JavaScript
      <script type="text/javascript"> function RefreshGrid() { grid.PerformCallback(); } </script>
      Visual Basic
      Protected Sub btnUpdate_Click(ByVal sender As Object, ByVal e As EventArgs) SaveData() ClientScript.RegisterStartupScript(Me.GetType(), "closescript", "<script language='javascript'>window.opener.focus(); window.opener.RefreshGrid(); window.close();</script>") End Sub

      I've attached the modified edition of the sample.
      Thanks,
      Serge

        Show previous comments (4)
        Serge (DevExpress Support) 16 years ago

          Vian,
          I see that your sample works fine, and the only task is to set up an intermediate buffer to store the changed made on the edit form and apply them only if the Update button is pressed, right? I recommend that you follow the approach illustrated in the example Implement on-demand data posting (batch data update). Just adapt the InvoiceItemsProvider class according to your data structure.
          Thanks,
          Serge

            hi Serge,
            Thanks for your reply. I've check on the example http://www.devexpress.com/example=E129, but I'm still not familiar on creating the classes according to the MDB structure (Just adapt the InvoiceItemsProvider class according to your data structure.) can the class be generated or it is declared manually?
            seems like it's populating the Grid using random data.

            Visual Basic
            Public Sub Populate() Dim res As BindingList(Of InvoiceItem) = GetItems() If res.Count > 0 Then Return End If Dim rnd As Random = New Random() For n As Integer = 0 To 9 Dim item As InvoiceItem = New InvoiceItem(res) item.Name = "Item" & res.Count.ToString() item.Price = (CDec(rnd.Next(1, 1000))) / 10 item.Quantity = rnd.Next(1, 5) res.Add(item) Next n End Sub

            Is there an example which work on an access or msSQL database structure?
            Appreciate the help,
            Vian

            Serge (DevExpress Support) 16 years ago

              Hi Vian,
              That is just a sample code. THis is why it uses random data. If you wish to adapt it to your existing DB structure, you should follow these steps:

              1. Change the members of the InvoiceItem class according to the structure of your data table.
              2. Change the InvoiceItemsProvider.Populate() method to load the necessary data from your data table and create an InvoiceItem instance for each data row.
              3. Change the InvoiceItemsProvider.Update() and InvoiceItemsProvider.Insert() methods to update the data in your data table.
                Of course, you can change all these classes names for better meeting the requirements you need.
                Thanks,
                Serge

              Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

              Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.