如何在一个jqxgrid中获取两个json对象数据?

时间:2016-07-25 10:38:45

标签: json ajax jqxgrid

我在ajax中工作我想将两个Json对象数据集成到一个单独的JqxGrid中。我可以在单独的网格中显示两个函数数据,任何正文可以帮助如何在单个网格中实现这个吗?有没有办法实现这个?我的功能就像这样

function functionname1(x, y) {
    $.ajax({
        type: "POST",
        url: "test.asmx/functionname1",
        data: "{'xx':'" + x + "','yy':" + y + "}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: OnSuccess

    });

    function OnSuccess(data, status) {
        var pointfeatures = [];
        var obj = JSON.parse(data.d);

        var source = {
            datatype: "json",
            datafields: [
                { name: 'field1' },
                { name: 'field2' }
            ],
            localdata: obj
        };
        var dataAdapter = new $.jqx.dataAdapter(source);
        $("#jqgrid").jqxGrid(
            {
                pagesize: 10,
                source: dataAdapter,
                width: 600,
                autoheight: true,
                columnsresize: true,
                columns: [

                              { text: '<b style="color:black;font-size:15px">fieldname</b>', datafield: 'field1', width: 'auto' },
                              { text: '<b style="color:black;font-size:15px">fieldname2</b>', datafield: 'field2', width: 'auto' }




                ]
            });

        var themesetting = { theme: 'darkblue' };
        $("#jqgrid").jqxGrid(themesetting);



}

还有一个功能

function functionname2(x, y) {
    $.ajax({
        type: "POST",
        url: "test.asmx/functionname2",
        data: "{'xx':'" + x + "','yy':" + y + "}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: OnSuccess

    });

    function OnSuccess(data, status) {
        var pointfeatures = [];
        var obj = JSON.parse(data.d);

        var source = {
            datatype: "json",
            datafields: [
                { name: 'field1' },
                { name: 'field2' }
            ],
            localdata: obj
        };
        var dataAdapter = new $.jqx.dataAdapter(source);
        $("#jqgrid").jqxGrid(
            {
                pagesize: 10,
                source: dataAdapter,
                width: 600,
                autoheight: true,
                columnsresize: true,
                columns: [

                              { text: '<b style="color:black;font-size:15px">fieldname</b>', datafield: 'field1', width: 'auto' },
                              { text: '<b style="color:black;font-size:15px">fieldname2</b>', datafield: 'field2', width: 'auto' }




                ]
            });

        var themesetting = { theme: 'darkblue' };
        $("#jqgrid").jqxGrid(themesetting);



}

0 个答案:

没有答案