Flexgrid as details on header/detail page

Posted by: travis on 15 August 2019, 8:54 am EST

    • Post Options:
    • Link

    Posted 15 August 2019, 8:54 am EST

    I’ve got a Flexgrid as part of an order/details page.

    I’ve got the code working such that when I create a new record on the grid it calls a sub routine to update it.

    The problem I have, is how do I pass additional information about the header to the new item so that I can associate them together? I need to pass the order id in some format to the sub that saves the record…

        Public Function GridCreate(<C1JsonRequest> ByVal requestData As CollectionViewEditRequest(Of OrderDetail)) As ActionResult
    
            For i = 0 To requestData.OperatingItems.Count - 1
                ' Database update code is here, but need the parent ID so they stick together!
            Next
    End Sub
    
    

    Thanks in advance!

  • Posted 15 August 2019, 6:58 pm EST

    Hi Travis,

    We are working on your case. We will give you an update as soon as possible.

    Regards,

    Ashwin

  • Posted 16 August 2019, 7:04 am EST

    I’ve been playing with this some and I think I have 2 possible solutions, but I can’t seem to make any of them work.

    • "

    • “Use batch edit, assign a hidden column for ID and then assign it to all values before you commit. My problem is cycling through the rows with Java.”

    • “Set a default value on the row when it’s created based on the value of a control on the form.”

    "

  • Posted 18 August 2019, 11:37 pm EST

    Hi Travis,

    As per original post, it seems you are using the Visual Basic but in your latest post you have mentioned JAVA.

    However, in case of ASP.NET MVC, you may use the following code for reference,

    @(Html.C1().CollectionViewService().Id("cvCustomers")
            .Bind(Url.Action("GridReadCustomer", "Home"))
        .Update(Url.Action("GridUpdateCustomer", "Home"))
    )
    <script id="detailTemplate" type="text/template">
        @(Html.C1().FlexGrid()
            .Height("200px")
            .AutoGenerateColumns(false)
            .Id("orderGrid")
            .Bind(b=>
            {
                b.Bind([b]Url.Action("GridReadOrder", "Home") + "?CustomerID={{CustomerID}}"[/b])
                .Update(Url.Action("GridUpdateOrder", "Home") + "?CustomerID={{CustomerID}}") ;
            })
            .Columns(columns =>
            {
                columns.Add(column => column.Binding("ShippedDate").Width("*"));
                columns.Add(column => column.Binding("Freight").Width("*").Align("Center"));
                columns.Add(column => column.Binding("ShipVia").Width("*").Align("Center"));
            })
            .ToTemplate()
        )
    </script>
    
    @(Html.C1().FlexGrid()
        .ShowDetailRow(d => d.DetailRowTemplateId("detailTemplate").DetailVisibilityMode(C1.Web.Mvc.Grid.DetailVisibilityMode.ExpandSingle).IsAnimated(true))
        .Id("detailRowFlexGrid")
        .ItemsSourceId("cvCustomers")
    )
    

    Also please find the attached sample:

    FlexGridDetailGrid_CRUD_Update.zip

    1. You may use the newItemCreator property of CollectionView accepting the Function which return default values for properties.
    <script>
        function SetDefault(s, e) {
            return { Name: 'Default', Color: 'Black' };
        }
    </script>
    @Html.C1().CollectionViewService().Bind(Model).NewItemCreator("SetDefault")
    

    Hope it helps!

    Regards,

    Manish Gupta

  • Posted 19 August 2019, 5:34 am EST

    The newItemCreator is exactly what I needed. I used that Java code to grab the order id number and use it as a default that gets passed back to the database code. Works perfectly now.

    Thanks!

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels