We have complex requirement where we want to sort the renderings at run time based on Filters For example : Assume that we have controller renderings say BC1,BC2,BC3,BC4 in sequence mentioned. Now problem this

Now we have filters in system where based on filtration BC1 may get removed and BC2 will take position of BC1 also BC3 will get position of BC2 and so on

Can some body help me with possible design

Regards UG

  • Are all of these controller renderings in the same placeholder? If so, this sounds like the default behavior to me. Maybe I'm not understanding correctly.
    – Ben Golden
    Sep 29 '17 at 3:40
  • Yes all of these are controller renderings this is not a default behavior as rendering position of BC1 will be taken by Rendering BC2 post filtration we need to change Rendering Order at runtime based on Filters Sep 29 '17 at 3:44
  • If these renderings are all bound to the same placeholder and one of the renderings is removed at runtime, then the renderings that were after it would "shift up". If you are seeing different behavior, then please include additional information about how your renderings are placed.
    – Ben Golden
    Sep 29 '17 at 4:40
  • Sorry what i forget to mention was in between BC1,BC2 and BC3 we have other renderings as well say CC1,CC2 and CC3 so overall rendering on layout are in this order : CC1,BC1,CC2,BC2,CC3,BC3,CC4,BC4 so postion of CC1 ,CC2,,CC3,CC4 is fixed where as based on filters rendering position of BC1 will be taken by Rendering BC2 post filtration. So challenge here is how do inject rendering BC2 in position of BC1 at runtime Sep 29 '17 at 4:55
  • 2
    I am down-voting the question because it omitted quite a lot of information as is shown in the comments. Please update the question to clearly explain the problem.
    – Ben Golden
    Sep 29 '17 at 13:36

Every B# Component (B1, B2, B3...) should have a cshtml file like:

<input type="hidden" data-selector="dynamic-component-placeholder" />
<div data-selector="dynamic-component" data-componentid="@Sitecore.Mvc.Presentation.RenderingContext.Current.Rendering.UniqueId">
  1. On document ready (assuming that you're using jQuery), create a list containing all the dynamic-component-placeholder hidden inputs.

  2. On document ready, create a list containing all the dynamic-component components.

  3. When Ajax call request returns response, remove all the dynamic-component components from the dom, create temporary list of filtered dynamic-component components and add them one by one AFTER the subsequent dynamic-component-placeholder.

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