0

I have a search results listing page where every search results are being updated using AJAX. I set a few rendering parameters like the number of results per page on the rendering because they need to vary between pages. Unfortunately, the Current Rendering item is not null only on the first page load, and then returns null with every AJAX request.

I'm trying to find the best way to obtain the parameters if I do not have the rendering item but I can pass eg. Rendering item Id in query string.

I was planning to :

  1. Pass rendering ID in query string
  2. Get the rendering item
  3. Assign current RenderingContext.Current.Rendering to the item from 2
  4. Invoke the rest of the logic as usual

I don't know how I should retrieve the rendering from ID to be able to assign it. I cannot just get the item because it's Rendering type, not Item type, can you please help? Maybe there is a better way to do it?

2

I would suggest a different approach that i usually use in situations like these,

  1. On the initial load of the page, add the rendering parameters values into the page as hidden input fields (input type: hidden), Or even like data attributes on one of the HTML elements.
  2. Create global javascript values that would read the values on these hidden fields as parameter object.
  3. When you submit your ajax/REST call, include the parameter object in the request.
  4. On your controller action, You can read the parameters values and use them to filter the search results.

Hope this helps

| improve this answer | |
  • This doesn't work if the rendering parameters contain data you don't want client side – Sean T Nov 4 at 11:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.