jQuery UI Widgets Forums TreeGrid Hierarchical top level

This topic contains 3 replies, has 2 voices, and was last updated by  svetoslav_borislavov 2 weeks ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • Hierarchical top level #133045

    ngchagas
    Participant

    How can I get Treegrid hierarchical top level with this json?

    
        var data = [
        {
            "id": "1",
            "nome": "REDE",
            "children": 
            [
                {
                    "id": "2",
                    "name": "1 - R1",
                    "children": 
                    [
                        {
                            "id": "3",
                            "name": "10 - LJ 10"
                        },
                        {
                            "id": "4",
                            "name": "11 - LJ 11"
                        },
                        {
                            "id": "4",
                            "name": "12 - LJ 12"
                        }
                    ]
                },
                {
                    "id": "5",
                    "name": "2 - R2",
                    "children": 
                    [
                        {
                            "id": "6",
                            "name": "20 - LJ 20"
                        },
                        {
                            "id": "7",
                            "name": "21 - LJ 21"
                        },
                        {
                            "id": "8",
                            "name": "22 - LJ 22"
                        }
                    ]
                },
                {
                    "id": "9",
                    "name": "3 - R3",
                    "children": 
                    [
                        {
                            "id": "10",
                            "name": "30 - LJ 30"
                        },
                        {
                            "id": "11",
                            "name": "31 - LJ 31"
                        },
                        {
                            "id": "12",
                            "name": "32 - LJ 32"
                        }
                    ]
                }
            ]
        }];
        var source =
        {
            dataType: "json",
            dataFields: [
                { name: "id", type: 'number' },
                { name: "name", type: "string" },
                { name: "children", type: "array" }
            ],
            hierarchy:
                {
                    root: "children"
                },
            localdata: data,
            id: "id"
        };
        var dataAdapter = new $.jqx.dataAdapter(source);
        $('treegrid').jqxTreeGrid(
            {
            source: dataAdapter,
            altRows: true,
            hierarchicalCheckboxes: true,
            checkboxes: true,            
            editable: true,
            height: 511,
            width: 875,
            columns: [
                { align: 'center',cellsalign: 'left', datafield: 'name',text: 'Filial',width: 400, filterable: false},
            ],
        });
    

    Example

    Hierarchical top level #133046

    Hi,

    I don’t understand, what you want to achieve. The code you sent creates the ‘What I want’ Grid from the image.
    Here is the demo with a similar code to yours: http://jsfiddle.net/956yr7Lb/3/

    Best regards,
    Svetoslav Borislavov

    jQWidgets Team
    https://www.jqwidgets.com/

    Hierarchical top level #133048

    ngchagas
    Participant

    Hi Svetoslav, thanks for reply.
    After my post I found that when the json is inside the code it works fine.
    When the json comes from the database API, no.
    The json api generate exactly the same format as I posted.
    Can there be any difference between the two json ?

    Hierarchical top level #133053

    Hi,

    May you send us an example in jsfiddle as the following one:
    http://jsfiddle.net/0zehvsy6/
    In the example from above, the data is a JSON string and it is working.

    Can you confirm that the JSON is valid?

    Best regards,
    Svetoslav Borislavov

    jQWidgets Team
    https://www.jqwidgets.com/

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

You must be logged in to reply to this topic.