Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5936593
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T15:25:14+00:00 2026-05-22T15:25:14+00:00

OK…I’ve spent too much time floundering on this one, so I’m passing it on

  • 0

OK…I’ve spent too much time floundering on this one, so I’m passing it on to the experts -> YOU.

My VERY simple ASP.NET MVC (v3 with Razor View Engine) page uses a Telerik Rad Grid control to show some type lists and then I have the associated codes showing in the DetailsView of the grid.

Doing the population is easy. I have a ViewModel for my TypeCodeList type and send it to the strongly typed view to populate the grid. This works GREAT…and the grid looks great – thanks Telerik. However, I added the DetailsView to then populate the child TypeCodes in the same manner. The bad thing is that when my grid populates, I select the triangle on the left to expand the tree and see the child records, nothing is there. BUT, if I select the “Refresh” button on the bottom of the grid, THEN I can hit the triangle and the child records display.

So (in summary), the child records do not show up on the initial load. Only when I select an AJAX refresh of the grid I get the children. Otherwise, it works as required.

I have been trying to see if I can programmatically kick off the refresh via javascrip upon page load. OR if I can get the thing to populate by itself when selected without doing a refresh first – that would be preferable.

Below is my code:

Pertinent Controller Code (I’ve taken out the update, delete, insert, logging and data access methods)

[HandleErrorWithElmah]
public partial class HostController : Controller
{

    /// <summary>
    /// Index - Home for HostController
    /// </summary>
    /// <returns></returns>
    public ActionResult Index()
    {
        return View();
    }

    #region Type List Section

    /// <summary>
    /// Gets the list of TypeLists - yea...say that again
    /// </summary>
    [GridAction]
    public ActionResult TypeCodeList()
    {

        var model = GetActiveTypeLists();

        // Get all of the type lists and send them to the view
        return View(model);

    }


    /// <summary>
    /// The ajaxified Select
    /// </summary>
    /// <returns></returns>
    [AcceptVerbs(HttpVerbs.Post)]
    [GridAction]
    public ActionResult _TypeCodeList()
    {

        var model = GetActiveTypeLists();
        return Json(new GridModel(model));


    }

    /// <summary>
    /// Simply a wrapper to get all of the current type list values.
    /// </summary>
    /// <returns></returns>
    private IEnumerable<TypeCodeListViewModel> GetActiveTypeLists()
    {

        var model = from p in entityRepository.Find<TypeList>(p => p.IsActive == true)
                    select new TypeCodeListViewModel
                    {
                        TypeListId = p.TypeListId,
                        Name = p.Name,
                        Description = p.Description,
                        IsActive = p.IsActive
                    };


        return model;

    }

    #endregion

    #region Type Code Section

    [AcceptVerbs(HttpVerbs.Post)]
    [GridAction]
    public ActionResult _TypeCodeForTypeListAjax(int typeListId)
    {
        var model = GetActiveTypeCodes(typeListId);
        return Json(new GridModel(model));
    }


    /// <summary>
    /// Simply a wrapper to get all of the current type Code values.
    /// </summary>
    /// <returns></returns>
    private IEnumerable<TypeCodeViewModel> GetAllActiveTypeCodes()
    {

        var model = from p in entityRepository.Find<OurLeaguePlay.Models.TypeCode>(p => p.IsActive == true).OrderBy(ord => ord.CodeName)
                    select new TypeCodeViewModel
                    {
                        TypeCodeId = p.TypeCodeId,
                        TypeListId = p.TypeListId,
                        CodeName = p.CodeName,
                        CodeValue = p.CodeValue,
                        Description = p.Description,
                        IsActive = p.IsActive
                    };


        return model;

    }


    /// <summary>
    /// Simply a wrapper to get all of the current type Code values.
    /// </summary>
    /// <returns></returns>
    private IEnumerable<TypeCodeViewModel> GetActiveTypeCodes(int typeListId)
    {

        var model = from p in entityRepository.Find<OurLeaguePlay.Models.TypeCode>(p => p.IsActive == true && 
                                                                                        p.TypeListId == typeListId).OrderBy(ord => ord.CodeName)
                    select new TypeCodeViewModel
                    {
                        TypeCodeId = p.TypeCodeId,
                        TypeListId = p.TypeListId,
                        CodeName = p.CodeName,
                        CodeValue = p.CodeValue,
                        Description = p.Description,
                        IsActive = p.IsActive
                    };


        return model;

    }


    #endregion

}

Here is my View Code:
(I’ve taken out all of my failed javascript attempts to try and force the load on page load.)

    @model IEnumerable<TypeCodeListViewModel>
@using Telerik.Web.Mvc.UI
@using Telerik.Web.Mvc
@using OurLeaguePlay.ViewModels
@{Html.Telerik().Grid<TypeCodeListViewModel>(Model)
        .Name("TypeLists")
        .DetailView(details => details.ClientTemplate(
            Html.Telerik().Grid<TypeCodeViewModel>()
                .Name("TypeCode_<#= TypeListId #>")
                .DataKeys(keys => keys.Add(k => k.TypeCodeId))
                .Columns(columns =>
                {
                    columns.Bound(o => o.CodeName).Width(40);
                    columns.Bound(o => o.CodeValue).ReadOnly(true).Width(40);
                    columns.Bound(o => o.Description).Width(100);
                })
                .DataBinding(dataBinding =>
                    {
                        dataBinding.Ajax().Select("_TypeCodeForTypeListAjax", "Host", new { typeListId = "<#= TypeListId #>" })
                                          .Enabled(true);
                    }
                    )
                .Pageable()
                .Sortable()
                .NoRecordsTemplate("No Type Codes exist for the selected Type List")
                .ToHtmlString()
            )
        )
        .DataKeys(keys => keys.Add(k => k.TypeListId))
        .Columns(columns =>
        {
            columns.Bound(o => o.Name).Width(100);
            columns.Bound(o => o.Description).Width(150);
            columns.Command(commands =>
            {
                commands.Edit().ButtonType(GridButtonType.Image);
                commands.Delete().ButtonType(GridButtonType.Image);
            }
                           ).Width(30);
        })
        .DataBinding(dataBinding =>
        {
            dataBinding.Ajax().Select("_TypeCodeList", "Host")
                              .Update("UpdateTypeList", "Host")
                              .Insert("InsertTypeList", "Host")
                              .Delete("DeleteTypeList", "Host")
                              .Enabled(true);
            dataBinding.Server().Select("TypeCodeList", "Host", new { ajax = ViewData["ajax"] });
        }
        )
        .Editable(editable => editable.Enabled(true).Mode(GridEditMode.InLine))
        .Pageable(page => page.PageSize(10))
        .Sortable()
        .Selectable()
        .Scrollable(scroll => scroll.Enabled(false))
        .NoRecordsTemplate("No Type Lists can be retrieved from the database")
        .ToolBar(commands => commands.Insert())
        .Render();
}

Finally…here are the ViewModel classes:

public class TypeCodeListViewModel 
{

    [ScaffoldColumn(false)]
    public int TypeListId { get; set; }

    [Required(ErrorMessage = "Required")]
    [StringLength(25, ErrorMessage = "Max Length is 25")]
    public string Name { get; set; }

    [Required(ErrorMessage = "Required")]
    [StringLength(25, ErrorMessage="Max Length is 25")]
    public string Description { get; set; }

    [ScaffoldColumn(false)]
    public bool IsActive { get; set; }


}

public class TypeCodeViewModel
{

    [ScaffoldColumn(false)]
    public int TypeCodeId { get; set; }

    [ScaffoldColumn(false)]
    public int TypeListId { get; set; }

    [Required(ErrorMessage = "Required")]
    [StringLength(25, ErrorMessage = "Max Length is 25")]
    [DisplayName("Name")]
    public string CodeName { get; set; }

    [Required(ErrorMessage = "Required")]
    [StringLength(25, ErrorMessage = "Max Length is 25")]
    [DisplayName("Value")]
    public string CodeValue { get; set; }

    [StringLength(500, ErrorMessage = "Max Length is 500")]
    public string Description { get; set; }

    [ScaffoldColumn(false)]
    public bool IsActive { get; set; }

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T15:25:15+00:00Added an answer on May 22, 2026 at 3:25 pm

    Well…I think I figured it out on my own…it was as simple as just letting the grid bind itself and not forcing data into it via the non-ajax method that gets called upon initial display of the page.

    The

    Public ActionResult TypeCodeList()
    

    function should simply be updated to the following:

    Public ActionResult TypeCodeList()
    {
        return View();
    }
    

    with no [GridAction] decorator.

    If you don’t force values into the grid, it will bind itself using the Ajax method and then the child grids will populate upon expansion.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an element like this: <span class=tool_tip title=The full title>The ful&#8230;</span> This seems
what about this one: I want to format the currentTime displayed by a videoPlayer
I have this xml <entry id=1008 section=articles> <excerpt><p>&#8230; in Richtung „Aus für Tierversuche. Kosmetik-Fertigprodukte
Why does the Android system throw this Exception? 05-18 12:33:44.169 W/System.err( 8230): java.io.IOException: Is
so I did $subject = 'sakdlfjsalfdjslfad <a href=something/8230>lol is that true?</a> lalalala'; $subject =
CGI.escapeHTML is pretty bad, but CGI.unescapeHTML is completely borked. For example: require 'cgi' CGI.unescapeHTML('&#8230;')
I want to run this <!-- This will remove the tag --> <xsl:template name=remove-html>
An Arabic name shall be sent via SOAP. The name is encoded like this:
I have a form, one of the fields is a select field, with 5
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.