jQWidgets Forums

jQuery UI Widgets Forums Grid Dont succeed to use map in datagrid source

Tagged: ,

This topic contains 5 replies, has 3 voices, and was last updated by  arunkumar.rc 9 years, 4 months ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author

  • lev_povolotsky
    Participant

    Hi,

    Please take a look this is my json responce

    {
        "result": [
            {
                "comment": null,
                "testComponents": [
                    {
                        "testComponentIdentifier": {
                            "componentName": "LP"
                        },
                        "versionMajor": "2",
                        "versionMinor": "0",
                        "versionPatch": "15721",
                        "versionBuild": "0",
                        "versionLabel": "SNAPSHOT"
                    }
                ],
                "testResult": [
                    {
                        "name": "OS",
                        "value": "AM"
                    }
                ],
                "testExecutionAverage": {
                    "testName": "TestNG_printVersions",
                    "average": 2873.44
                }
            }
        ],
        "totalrecords": 1
    }

    and this is the code that read it:

     var data = (function () {
                    var json = null;
                    $.ajax({
                        'async': false,
                        'global': false,
                        'url':host + "testexecution/gettestalldataaccordingtotestExecutionId",
                        'dataType': "json",
                        'data': 'testExecutionId=' + <c:if test="${!empty testExecutionId}">${testExecutionId}</c:if> ,
                        'success': function (data) {
                            json = data;
                        }
                    });
                    return json;
                })();
    
             var componentsDataGridSource =
                {
                    dataType: "json",
                    dataFields: [
                        { name: 'componentName',map: 'testComponents>testComponentIdentifier>componentName' },
                        { name: 'versionMajor', map: 'testComponents>versionMajor'},
                        { name: 'versionMinor', map: 'testComponents>versionMinor'  },
                        { name: 'versionPatch', map: 'testComponents>versionPatch' },
                        { name: 'versionBuild', map: 'testComponents>versionBuild'},
                        { name: 'versionLabel', map: 'testComponents>versionLabel'  }
    
                    ],
                    root: 'result',
                    localdata: data
                };
    
     var componentsGridDataAdapter = new $.jqx.dataAdapter(componentsDataGridSource );
    
                $("#jqxcomponentsgrid").jqxGrid(
                        {
                            width: 1240,
                            height: 150,
                            source: componentsGridDataAdapter,
                            theme: theme,
                            columnsresize: true,
                            columns: [
                                { text: 'Component Name', datafield: 'componentName', width: 160 },
                                { text: 'Version Major', datafield: 'versionMajor', width: 130 },
                                { text: 'Version Minor', datafield: 'versionMinor', width: 150 },
                                { text: 'Version Patch', datafield: 'versionPatch', width: 160},
                                { text: 'Version Build', datafield: 'versionBuild', width: 160 },
                                { text: 'Version Label', datafield: 'versionLabel', width: 150 }
    
                            ]
                        }
                );

    can you explain me why it’s not working why I don’t get the data inside my grid


    Peter Stoev
    Keymaster

    Hi lev_povolotsky,

    The problem in this code is that “result” is not the “root”. The root is actually the first item of the result which is array for some reason. The solution is: either make the “result” to be a normal object in the returned JSON or update the source object by making the root to point to the result’s first item or remove the “root” and update your “map” settings by adding result>0 in front of each.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com


    lev_povolotsky
    Participant

    I return it as regular list of object.

    The other solution I tried and it still doesn’t work for me, still get empty.

     var componentsDataGridSource =
                {
                    dataType: "json",
                    dataFields: [
                        { name: 'componentName',map: 'result>testComponents>testComponentIdentifier>componentName' },
                        { name: 'versionMajor', map: 'result>testComponents>versionMajor'},
                        { name: 'versionMinor', map: 'result>testComponents>versionMinor'  },
                        { name: 'versionPatch', map: 'result>testComponents>versionPatch' },
                        { name: 'versionBuild', map: 'result>testComponents>versionBuild'},
                        { name: 'versionLabel', map: 'result>testComponents>versionLabel'  }
    
                    ],
                    localdata: data
                };

    Can you help me with that please?


    lev_povolotsky
    Participant

    I also tried the other option no as array at json and no result and also not working

    {
                "comment": null,
                "testComponents": [
                    {
                        "testComponentIdentifier": {
                            "componentName": "LP"
                        },
                        "versionMajor": "2",
                        "versionMinor": "0",
                        "versionPatch": "15721",
                        "versionBuild": "0",
                        "versionLabel": "SNAPSHOT"
                    }
                ],
                "testResult": [
                    {
                        "name": "OS",
                        "value": "AM"
                    }
                ],
                "testExecutionAverage": {
                    "testName": "TestNG_printVersions",
                    "average": 2873.44
                }
    }
     var componentsDataGridSource =
                {
                    dataType: "json",
                    dataFields: [
                        { name: 'componentName',map: 'testComponents>testComponentIdentifier>componentName' },
                        { name: 'versionMajor', map: 'testComponents>versionMajor'},
                        { name: 'versionMinor', map: 'testComponents>versionMinor'  },
                        { name: 'versionPatch', map: 'testComponents>versionPatch' },
                        { name: 'versionBuild', map: 'testComponents>versionBuild'},
                        { name: 'versionLabel', map: 'testComponents>versionLabel'  }
    
                    ],
                    localdata: data
                };
    
     var componentsGridDataAdapter = new $.jqx.dataAdapter(componentsDataGridSource );
    
                $("#jqxcomponentsgrid").jqxGrid(
                        {
                            width: 1240,
                            height: 150,
                            source: componentsGridDataAdapter,
                            theme: theme,
                            columnsresize: true,
                            columns: [
                                { text: 'Component Name', datafield: 'componentName', width: 160 },
                                { text: 'Version Major', datafield: 'versionMajor', width: 130 },
                                { text: 'Version Minor', datafield: 'versionMinor', width: 150 },
                                { text: 'Version Patch', datafield: 'versionPatch', width: 160},
                                { text: 'Version Build', datafield: 'versionBuild', width: 160 },
                                { text: 'Version Label', datafield: 'versionLabel', width: 150 }
    
                            ]
                        }
                );

    and that’s still not working


    lev_povolotsky
    Participant

    Please help me I really need a solution for that

    Dont succeed to use map in datagrid source #79137

    arunkumar.rc
    Participant

    lev_povolotsky: did you find any solution for this issue ? I am floating in the same boat right now ! Any help or suggestion will be appreciated

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

You must be logged in to reply to this topic.