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
20
Tile Manager and bind Json Sample
posted

Hi,

Just started evaluating the tool set to replace a WPF Dashboard that loads tile based on the user preference. In the current sample set, the "JSON" data source is <script src="../../data-files/recipes.js"></script> with a predefined

items: [
                    { rowIndex: 0, colIndex: 0, rowSpan: 1, colSpan: 1 },
                    { rowIndex: 0, colIndex: 1, rowSpan: 2, colSpan: 2 },
                    { rowIndex: 1, colIndex: 0, rowSpan: 1, colSpan: 1 },
                    { rowIndex: 2, colIndex: 0, rowSpan: 1, colSpan: 1 },
                    { rowIndex: 2, colIndex: 1, rowSpan: 1, colSpan: 1 },
                    { rowIndex: 2, colIndex: 2, rowSpan: 1, colSpan: 1 }
                ],

Is there an example that uses a JSON call to retrieve the data and then configures items accordingly?
  • 20255
    Offline posted

    Hello Adrian,

    Thank you for your question.

    I am glad to see that you are looking at our "Bind to JSON" sample.

    If you want to get your data from some external source or MVC controller for example, you can use ajax calls like:

    $.ajax({
      type: 'get',
      dataType: 'json',
      cache: false,
      url: '/MyController/MyMethod',
      data: { keyid: 1, newval: 10 },
      success: function (response, textStatus, jqXHR) {
        alert(parseInt(response.oldval + ' changed to ' + newval));                                   
      }
    });


    [HttpGet]
    public ActionResult MyMethod(int keyid, int newval)
    {
     ....
        return Json(new { success = true, oldval = oldval},
                    JsonRequestBehavior.AllowGet);
    }



    Or you can use getJSON:

    $.getJSON('http://example/functions.php', { get_param: 'value' }, function(data) {
        $.each(data, function(index, element) {
            $('body').append($('

    ', {


                text: element.name
            }));
        });
    });

    Once the JSON is received you can set it as "dataSource" to your tileManager.

    Let me know if I can be of further assistance.

    Helpful references:

    http://stackoverflow.com/questions/8951810/how-to-parse-json-data-with-jquery-javascript

    http://stackoverflow.com/questions/227624/asp-net-mvc-controller-actions-that-return-json-or-partial-html