jQWidgets Forums

jQuery UI Widgets Forums Grid Associated objects

This topic contains 3 replies, has 2 voices, and was last updated by  Peter Stoev 13 years ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • Associated objects #3244

    Black Moon
    Member

    Hi All!

    How is it possible to load associated object through json or xml data.

    Here’s source obj

    var rsource = {
    datatype: "xml",
    datafields: [{ name: 'Name' }, { name: 'Descr' }, { name: 'Permissions' }],
    root: "Roles",
    record: "Role",
    id: 'Id',
    url: '/Cache/roles.xml',
    };

    And xml file

    '<?xml version="1.0" encoding="utf-8"?>
    '<Roles>
    ' <Role Id="385cd9c4-8b7d-e111-a93e-50e549a5b361">
    ' <Name>New name111</Name>
    ' <Descr>роль пользователя111</Descr>
    ' <Datecreate>03.04.2012</Datecreate>
    ' <Usercreate>430d4bda-4c0c-4e5a-a443-b7091ef1e98c</Usercreate>
    ' <Permissions>
    ' <Permission Action="AdminController:edit">true</Permission>
    ' <Permission Action="AdminController:view">true</Permission>
    ' </Permissions>
    ' </Role>
    '</Roles>

    The purpose is to load data source which have simple fields (Name, id) and complex (permissions).
    Thanks

    Associated objects #3254

    Peter Stoev
    Keymaster

    Hi Black Moon,

    It is possible to specify a mapping(path) to a property in the data source(this is demonstrated in the binding to xml demo). In your data source, you have a property Permissions which has 2 or more sub properties. When the Grid is bound, it will read the contents of that property and will display them. With the given xml data, the result will be ‘truetrue’. If you had property names like: Permission1, Permission2, then it would be possible to display these properties in different columns by specifying a path to them. However, with this data, this is not possible, at least with the built-in data binding. My suggestion in your scenario is to manually parse your xml data and save it in an Array object. Then load the Grid from the Array.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    Associated objects #3258

    Black Moon
    Member

    Hi Petr,
    Thanks for idea, but

    1. what is the methor in grid or in source object where outer xml file is parsing into data?
    2. which datatype is faster for parsing (array, json, xml – xml and json anre on the same domain)?

    Associated objects #3267

    Peter Stoev
    Keymaster

    Hi Black Moon,

    1. The Grid does not expose public methods for parsing data. It expects its source property to be set to a source or a dataAdapter object and then it calls the appropriate data loading functions depending on the datatype – json, xml, jsonp, csv, tsv or something else.

    2. Most of the data types require a jQuery selection depending on the souce object’s root and record property values. However, if you load the data from array, this is not necessary i.e the fastest data loading is from an array object.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.