@model IEnumerable<kendoBatchHeaderTest.Models.BatchHeader>

@{
    ViewBag.Title = "Transaction Review";
}

<h2>Batches to Review/Post</h2>

@(Html.Kendo().Grid(Model)
    .Name("BatchGrid")
    .Pageable()
    .Sortable()
    .Scrollable()
    .Columns(columns =>
                {
                    columns.Bound(b => b.BatchID)
                                        .Width("100")
                                        .Title("Batch ID");
                    columns.Bound(b => b.Created_DTTM)
                                        .Width("175")
                                        .Format("{0:MM/dd/yyyy hh:mm tt}")
                                        .Title("Created");
                    columns.Bound(b => b.PostingStatus)
                                        .Width("175")
                                        .Title("Status");
                }
            )
    .DataSource(dataSource => dataSource
        .Ajax()
        .PageSize(40)
        .Read(read => read.Action("FetchBatchCollection", "Home"))
    )
    .ClientDetailTemplateId("transactions")
    .Events(events => events.DataBound("dataBound"))
)

<!-- Nested grid for transaction object, member of BatchHeader.TranCollection
     There can be many ITransaction objects per BatchHeader -->
<script id="transactions" type="text/kendo-tmpl">
    @(Html.Kendo().Grid<kendoBatchHeaderTest.Models.Transaction>()
            .Name("TranGrid")
            .Columns(columns =>
                {
                    columns.Bound(b => b.ID)
                                        .Width("100")
                                        .Title("Transaction ID");
                    columns.Bound(b => b.TranType)
                                        .Width("200")
                                        .Title("Type");
                     columns.Bound(b => b.PostingMessage)
                                        .Width("600")
                                        .Title("Posting Message");
                }
            )
            .DataSource(dataSource => dataSource
                .Ajax()
                .PageSize(5)
                .Read(read => read.Action("FetchTransactionCollection", "Home", new { batchID = "#=BatchID#" }))
            )
            //.ClientDetailTemplateId("detailTransactions")
            .Events(events => events.DataBound("dataBound"))
            .ToClientTemplate()
    )

</script>

@{
    var secondModel = (System.Data.DataTable)ViewData["secondModelDataTable"];
 }

<!-- Nested grid for detail transaction object. There is only one per transaction object -->
@*<script id="detailTransactions" type="text/kendo-tmpl">
    @(Html.Kendo().Grid<System.Data.DataRow>()
            .Name("DetailTranData")
            .Columns( columns =>
                    {
                        foreach (System.Data.DataColumn col in secondModel.Columns)
                        {
                            // suppress all of the following columns as the
                            // data is either redundant to prior grid levels
                            // or is not relevant to the display need
                            if (col.ColumnName == "NonDisplayProperty") 
                            {
                                continue;
                            }
                            // display all other columns
                            columns.Bound(col.ColumnName).Title(col.Caption)
                                                            .Width(200);
                        }
                    }
             )
            .Scrollable()
            .Pageable()
            .DataSource(dataSource => dataSource
                .Ajax()
                .Model(model =>
                    {
                        foreach (System.Data.DataColumn col in secondModel.Columns)
                        {
                            model.Field(col.ColumnName, col.DataType);
                        }
                    }
                )
                .Read(read => read.Action("FetchDetailTransactionDataTable", "Home",
                                            new
                                            {
                                                batchID = "#=BatchID#",
                                                tranID = "#=TransactionID#",
                                                trantype = "#=TransactionType#"
                                            }
                                         )
                )
            )
            .ToClientTemplate()
    )
</script>*@

<script type="text/javascript">
   function dataBound() {
        this.expandRow(this.tbody.find("tr.k-master-row").first());
    }
</script>
        