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 9083795
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T20:51:25+00:00 2026-06-16T20:51:25+00:00

I´m faced with what is probably just a small oversight on my behalf, but

  • 0

I´m faced with what is probably just a small oversight on my behalf, but I´m trying to serialize a complex class in my View. I keep getting a circular reference when running this code.

Controller:

public JsonResult EditPrice(int id)
{
    Category cat = _categoryDataGateway.GetCategory(id);
    return Json(new {category = cat}, JsonRequestBehavior.AllowGet);
}

Jquery:

<script type="text/javascript">
function PriceChange(e) {
    if (e.name == "PriceCategory") {
        var priceWindow = $("#PriceWindow").data("tWindow");
        var category = e.response.category;
        $("#PriceDetails")
            .find("h2")
            .text(category.Name);
        priceWindow.center().open();
    }
}
</script>

View + Telerik:

<div>
    @(Html.Telerik().Grid(Model)
    .Name("CategoryList")
    .Localizable("is-IS")
    .Columns(columns =>
    {
        columns.Bound(o => o.Name).Width("20%");
        columns.Bound(o => o.Id).Template(o => Html.Label(o.SuperCategory())).Title("Yfirflokkur").Width("15%");
        columns.Bound(o => o.Description).Width("35%");
        columns.Command(command =>
        {
            command.Custom("EditCategory").Text("Edit").Action("Edit", "Category").DataRouteValues(r => r.Add(k => k.Id));
            command.Custom("PriceCategory").Text("Price").Action("EditPrice", "Category").DataRouteValues(r => r.Add(k => k.Id).RouteKey("Id")).Ajax(true);
            command.Custom("DeleteCategory").Text("Delete").Action("Delete", "Category").DataRouteValues(r => r.Add(k => k.Id));
        }).Width("30%").Title("Actions");
    })
    .ClientEvents(events => events.OnComplete("PriceChange"))
    .Sortable()
    .Footer(false)
)
</div>
<div>
    @(Html.Telerik().Window()
        .Name("PriceWindow")
        .Visible(false)
        .Title("Price")
        .Modal(true)
        .Width(500)
        .Height(200)
        .Content(@<text>
                    <div id="PriceDetails">
                        <h2></h2>
                        <div>
                            <input id="CategoryPrice" type="text"/>
                        </div>
                        <div>
                            <button>Submit</button>
                        </div>
                    </div>
            </text>)
    )
</div>

My goal is to be able to press the “Price” button in the grid and a window pops up that allows me to change the price. The thing is that I´ve already been able to use this code and send a simple string to the view and that works perfectly, for instance sending “cat.Name” from my controller instead of only “cat”, so basically when I send the complex type “Category” I get the circular reference.
Can any1 spot my failure? 🙂

  • 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-06-16T20:51:26+00:00Added an answer on June 16, 2026 at 8:51 pm

    I belive I will answer my own question. Shortly after I posted the question I tried something else and it worked, like this:

    Controller:

    public JsonResult EditPrice(int id)
    {
        Category cat = _categoryDataGateway.GetCategory(id);
        return Json(new {Id = cat.Id, Name = cat.Name}, JsonRequestBehavior.AllowGet);
    }
    

    Jquery:

    <script type="text/javascript">
    function PriceChange(e) {
        if (e.name == "PriceCategory") {
            var priceWindow = $("#PriceWindow").data("tWindow");
            var id = e.response.Id;
            var name = e.response.Name;
            $("#PriceDetails")
                .find("h2")
                .text(name)
                .end()
                .find("#CategoryIdHidden")
                .attr("value", id);
            priceWindow.center().open();
        }
    }
    </script>
    

    Telerik Window:

    <div>
        @(Html.Telerik().Window()
            .Name("PriceWindow")
            .Visible(false)
            .Title("Verð")
            .Modal(true)
            .Width(300)
            .Height(200)
            .Content(@<text>
                        <div id="PriceDetails">
                            <h2></h2>
                            <div>
                                <input id="CategoryPrice" type="text"/>
                                <input id="CategoryIdHidden" type="hidden"/>
                            </div>
                            <div>
                                <span class="art-button-wrapper"onmouseover="className='art-button-wrapper hover'"
                                        onmouseout="className='art-button-wrapper'">
                                    <span class="art-button-l"></span><span class="art-button-r "></span>
                                    <button class="art-button">Breyta verði</button>
                                </span>
                            </div>
                        </div>
                </text>)
        )
    </div>
    

    The thing is that I just had to take the bits from my complex type and send it separately to the view to be serialized there. Thank you anyway 🙂

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

Sidebar

Related Questions

Probably a too special question, but just in case someone has faced a similar
This is probably a really simple question, and I'm just not getting it. I'd
I'm probably just being neurotic, but I regularly find myself in situations in which
I faced SSLHandshakeException on Heroku. This app was not SSL app. But this app
I work for a very small company. I was recently faced with the question
The solution is probably staring me in the face, but I haven't had any
This is a probably a dumb question but here is what I've got. A
This is probably a simple question, bu I just can't find the answer I'm
This is a very simple, probably too simple question but I'm afraid my limited
I faced following issue with my work: having two projects: MFC .dll and MFC

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.