Rendering or Appending a View in a Container

8 posts, 0 answers
  1. mgs
    mgs avatar
    163 posts
    Member since:
    Jan 2011

    Posted 04 Mar 2013 Link to this post

    Reading http://docs.kendoui.com/getting-started/framework/spa/view I understand that the "render" method renders a view inside a container by replacing the current content with the new content.

    However, when testing, I did not see that behaviour. Actually on "render" the view is appended to the current content, inside the wrapping "div" element.

    Michael G. Schneider
  2. Petyo
    Admin
    Petyo avatar
    2439 posts

    Posted 04 Mar 2013 Link to this post

    Hi Michael,

    The behavior you describe (replacement of content) is a responsibility of the showIn method of the layout.

    Can you please point us to the part in the documentation that states otherwise (or somehow implies) that the view render method replaces the container contents? I re-read it, and I think that we have used 'append' to describe what happens. Most probably I am missing something.

    Thank you in advance,
    Petyo
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!

  3. Kendo UI is VS 2017 Ready
  4. mgs
    mgs avatar
    163 posts
    Member since:
    Jan 2011

    Posted 04 Mar 2013 Link to this post

    Hello Petyo,

    thanks a lot for the answer. English not being my first language I should not try to proofread a text.

    I once again read that topic. I think my assumption came from the following.

    • There is a chapter "Appending View Element". So if there is a way for appending the view, the "render" call will probably replace the contents.
    • In the chapter "Appending View Element" the sentence below the source code starts with "Subsequent reder calls will not re-instantiate ... but append ...". This sentence would make sense, if it had appeared in the previous chapter "Rendering View in a Container". So I did not take it serious, and thought it should have read "Subsequent append calls...".
    Michael G. Schneider
  5. Petyo
    Admin
    Petyo avatar
    2439 posts

    Posted 05 Mar 2013 Link to this post

    Hello Michael,

    Thank you for your input - I have re-ordered the docs as per your suggestion. This should hopefully save some confusion for our users.

    Regards,
    Petyo
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  6. mgs
    mgs avatar
    163 posts
    Member since:
    Jan 2011

    Posted 05 Mar 2013 Link to this post

    Hello Petyo,

    thanks a lot for the answer. The change to the documentation is only internal, it is not yet visible for the public. Or should I see it?

    Michael G. Schneider
  7. Petyo
    Admin
    Petyo avatar
    2439 posts

    Posted 07 Mar 2013 Link to this post

    Hi Michael,

    The change is yet to be published on the docs site - you can follow the changes in the master branch of the kendo-docs github repository

    Regards,
    Petyo
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  8. Steve
    Steve avatar
    1851 posts
    Member since:
    Dec 2008

    Posted 25 Jun 2013 Link to this post

    @Michael

    Did you ever get this to work?  I also just noticed "render" on a view was appending into the container.

    I don't understand the layout and view concepts maybe?  Why do we need both?

    Is layout the like "Masterpage" and the views are the "ContentPlaceholders\pages"?

    Steve
  9. mgs
    mgs avatar
    163 posts
    Member since:
    Jan 2011

    Posted 26 Jun 2013 Link to this post

    Hello Steve,

    if I remember correctly, the problems that I discussed in this post were caused by me misunderstanding  the initial version of the documentation. There were no real problems with Kendo SPA. So yes, I made it work.

    I prepared two small samples, showing some basics. One sample is without a layout, and the other one uses a layout. You can find them here...

    Without a layout: http://jsfiddle.net/mgs_jsfiddle/w6dhf/
    With a layout: http://jsfiddle.net/mgs_jsfiddle/RtAeB/

    Using a layout brings the benefit that you can have several areas, where content can be placed into. Not using a layout causes the content to be added to the container, whereas using a layout always replaces the container's content.

    I think that "adding / replacing" is no natural consequence of "without layout / with layout". With SPAs you probably always want a "replace". So if not using the layout you have to remove the previous content before the render-call.

    I always use "with layout", even if there is just a single area to be rendered.

    Michael G. Schneider
Back to Top
Kendo UI is VS 2017 Ready