jQuery UI Widgets Forums Plugins Data Adapter dataadapter inner array

This topic contains 2 replies, has 2 voices, and was last updated by  billelmehdi 1 month ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • dataadapter inner array #111851

    billelmehdi
    Participant

    Hi,

    I have the following source:

    var data =
    [{
    “Employee”: “John Doe”,
    “JobCode”:
    [
    { “Id”: 1, “Code”: “A” },
    { “Id”: 2, “Code”: “B” }
    ]
    },
    {
    “Employee”: “Toto”,
    “JobCode”:
    [
    { “Id”: 3, “Code”: “C” },
    { “Id”: 4, “Code”: “D” }
    ]
    }];

    var source = {
    datatype: ‘json’,
    mapChar: ‘>’,
    localdata: data,
    datafields:
    [
    { name: ‘Employee’, map: ‘Employee’ },
    { name: ‘JobCode’, type: ‘array’ },
    { name: ‘CodeName’, map: ‘JobCode>Code’ }
    ]
    };
    var dataAdapter = new $.jqx.dataAdapter(source);

    $(“#jqxgrid”).jqxGrid({
    source: dataAdapter,
    columns:
    [
    { text: ‘Employee Name’, datafield: ‘Employee’, width: 200 },
    { text: ‘Job Code A’, datafield: ‘CodeName’, width: 200 }
    ]
    });

    How can I access to the Code field in such way to display in the grid the Code beside the employee name?

    How to handle a field in inner array?

    Thanks.

    dataadapter inner array #111856

    Hristo
    Participant

    Hello billelmehdi,

    You could process the result into the desired format with the beforeLoadComplete callback of the jqxDataAdapter.
    Also, I would like to mention there is no clear determination about which should be the right element for each one cell of the records.
    Please, take a look at this example:
    jsfiddle.net/p7d0noL4/4/

    Best Regards,
    Hristo Hristov

    jQWidgets team
    https://www.jqwidgets.com

    dataadapter inner array #111864

    billelmehdi
    Participant

    Thank you for your reply Hristo.

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

You must be logged in to reply to this topic.