0

This is the JS I call in Index on document ready

jsonfields = @Html.Raw(Json.Encode(ViewBag.ColumnData));

This is the Ajax Call which I Make to bind

function onTeamTreeLoad(e) {
    try {
        $.ajax({
            type: "POST",
            url: window.ApplicationPath + 'Generic/GetTeamTree',
            dataType: "json",
            headers: { "__RequestVerificationToken": $("#AntiForgeryToken").val() },
            contentType: 'application/json',
            success: function (data) {
                if (data != null) {
                    $("#TeamName").kendoDropDownTree({
                        dataSource: {
                            schema: {
                                model: {
                                    children: "Items"
                                }
                            },
                            data: data
                        },
                        dataTextField:  "Text",
                        dataValueField: "Id"
                    });

                    try {
                        if (e.model.TeamName !== "") {
                            $("#TeamName").data("kendoDropDownTree").text(e.model.TeamName);
                        }
                    } catch (e) { }
                }
            },
            error: function () {
                console.log('Failed to load');
            }
        });
    } catch (e) {
        console.log(e);
    }
}

Why am I seeing [objectObject] when trying to bind the column? I want the data to be viewed instead of objectObject. I tried adding SerializeObject method to ID and Text but then I could not view that column when editing! I would like to know if there is any mistake in the AJAX call and what are the things that need to be added if using SerializeObject or JSON.Stringify.

Fai Jaan
  • 1
  • 1

1 Answers1

0

Here you are just printing object. So Object -> Stringify give output like [object Object].

You can try this code.

for(var prop in obj) {
  console.log(obj[prop]);
}
ksilentstorm
  • 105
  • 9