Grid within a razor foreach loop

2 posts, 0 answers
  1. Paul
    Paul avatar
    13 posts
    Member since:
    Sep 2015

    Posted 06 Oct 2015 Link to this post

    Here is my dilema,

    I have a foreach loop over a simple model like this


    fund list

    fundint int,

    fundname varchar


    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.

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

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

  2. Dimiter Madjarov
    Dimiter Madjarov avatar
    2306 posts

    Posted 08 Oct 2015 Link to this post

    Hello Corey,

    You could pass the id via object route value.

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

    Let me know if this information helps.

    Dimiter Madjarov
    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
Back to Top