This is a migrated thread and some comments may be shown as answers.

Grid within a razor foreach loop

1 Answer 680 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Paul
Top achievements
Rank 1
Paul asked on 06 Oct 2015, 06:15 PM

Here is my dilema,

I have a foreach loop over a simple model like this

Model

fund list

fundint int,

fundname varchar

etc.

i am looping through a list of funds above and would like to have a Kendo grid populated with data from the controller for each fundint in the foreach.

        <table>
            @foreach (var item in Model)
            {
                <tr>
                    <td>@Html.DisplayFor(modelItem => item.FUND_INT_ID)
                    </td>
                <tr>
                    <td>
                    @(Html.Kendo().Grid<BetaSMTRApp.Models.Private_Report_Card_Companies_Single_Result>()
     .Name("AjaxGrid")
                                .AutoBind(true)                                                                       .Columns(columns =>
             {
                                                                              columns.Bound(c => c.CompanyName).Title("Company Name").Width(150);
                                                                       })
                                                                          .ColumnMenu()
                                                                          .HtmlAttributes(new { style = "height:600px;" })
                                                                          .DataSource(dataSource => dataSource
                                                                              .Ajax()
                                                                              .Read(read => read.Action("GetPortfolioCompanies", "PrivateReportCard").Data("additionalInfo"))
                                                                          )
                                    )
                    </td>
 
<script>
    function additionalInfo() {
        var frominfo = $("#asofdate").val();
        var fundinfo = $("#fundint").val();
        return { AsOfDate: frominfo, FundInt: fundinfo};
    }
</script>

How do i pass the FUND_INT_ID in the foreach loop to the GetPortfolioCompanies function in the controller?

1 Answer, 1 is accepted

Sort by
0
Dimiter Madjarov
Telerik team
answered on 08 Oct 2015, 08:06 AM

Hello Corey,

You could pass the id via object route value.
E.g.

.Read(read => read.Action("ActionName", "ControllerName", new { id = ... }))

Let me know if this information helps.

Regards,
Dimiter Madjarov
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Grid
Asked by
Paul
Top achievements
Rank 1
Answers by
Dimiter Madjarov
Telerik team
Share this question
or