How to output a raw JSON page from a Kentico Repeater in Portal Design mode

Chloe Imogen asked on October 3, 2019 12:16

In Portal Mode how can I cause a page to output just the data of its Repeater web part without the page wrapper asp.net form, etc?

I've set page Template inheritance to none, unchecked header inheritance, but to no avail, am still getting theme elements, asp.net form, html tag head, body and the norm. I'm looking to get rid of all those peripheral html elements and keep just the repeater output which is raw JSON.

What I'm trying to achieve is to output raw JSON to page using a Repeater Web Part while keeping the Repeater in the CMS Design UI where it's easy to manage by Admins. The RAW JSON will be picked up by a JQuery.get(..) or equivalent to read JSON and parse it, as per usual.

I've tried combining the Kentico Custom Response web part with a Repeater on the same page, but the Custom Response blows away any other page output of course.

I'm willing to dip into ASPX + Portal template combo mode if necessary, but want to keep using Kentico web parts in the Design interface to produce the data.

I found a Custom Response Repeater web part on DevNet however would rather manage the Design mode myself because I might want to throw some additional web parts in there.

Ultimately if it's not doable or involves too much complexity I'll use a good old ASP.NET ASHX Handler to produce what I need from the Kentico API and leave Kentico Design mode out of the equation altogether.

Thanks.

Recent Answers


David te Kloese answered on October 3, 2019 15:49

In Portal only setting custom response headers will allow you to use it this way.

So if you want to use the repeater, create a clone and update it to send a custom JSON response when on live site mode.

0 votesVote for this answer Mark as a Correct answer

Peter Mogilnitski answered on October 3, 2019 16:36 (last edited on December 10, 2019 02:31)

Custom response web part + macro should do the trick. You can create your custom web part if you want to (essentially you will have to merge custom response and repeater). Here is example converting custom table to json. The macro below will generate the JSON:

[
{% GlobalObjects.CustomTables["customtable.SampleTable"].Items.ApplyTransformation("{\"ID\":\"{#ItemID#}\",\"Text\":\"{#ItemText#}\"},").TrimEnd(",")|(identity)GlobalAdministrator%}
]
0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.