Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
2585
Binding JSON Datasource with razor
posted

Is there a special way to bind a JSON Datasource to the TileManager with Razor? We are trying the below and receiving an error.

            IList<Person> list = new List<Person>();
            list.Add( new Person(){Name="MDL"});

            return HtmlHelperExtensions.Infragistics(helper)
                .TileManager()
                .ID("dashboard")
                .DataSourceType("JSON")
                .DataSource(JsonConvert.SerializeObject(list))
                .Render();
Error: Cannot determine the data source type. Please specify if it is JSON or XML data.

  • 540
    Suggested Answer
    posted

    Hello Tammy,

    As we have released the RTM version of the Tile Manager the content template property was removed.
    Each tile now has two states - maximized and minimized and they have separate templates.
    To databind to a Datasource you can do as Nikolay showed in his example, just change the .ContentTemplate().

    Example:

    @(Html.Infragistics().TileManager()
        .ID("dashboard1")
        .DataSource(list.AsQueryable())
        .MinimizedState("<h3>${Name} minimized content</h3>")
        .MaximizedState("<h3>${Name} maximized content</h3>")
        .DataBind()
        .Render()
    )

  • 37874
    posted

    Hi Tammy,

    I tested your code and I would suggest you to modify it as follows:

     

    Code Snippet
    1. @(Html.Infragistics().TileManager()
    2.  .ID("dashboard1")
    3.  .DataSource(list.AsQueryable())
    4.  .ContentTemplate("<h3>${Name}</h3>")
    5.  .DataBind()
    6.  .Render()
    7.  )

    Now it should be working correctly.

    Let me know if you have any other questions.