jquery如何处理地图?

时间:2014-03-10 11:37:40

标签: javascript jquery spring maven

我正在用maven做一个spring mvc项目..我想显示一个带有items..am的jqxGrid通过MAP获取项目..问题是,我有网格但没有项目显示......数据从控制器返回map..how jquery处理这个返回的地图??

我的jquery代码

       $(document).ready(function () {
             var source =
                {     
                    datatype: "json",
                    type:"GET",
                    url: "account/list",
                    datafields: [
                        { name: 'id' },
                        { name: 'periodname' },
                        { name: 'startdate' },
                        { name: 'enddate' },
                        { name: 'isactive' }
                    ],
                    sort: function () {
                        $("#jqxgrid").jqxGrid('updatebounddata', 'sort');
                        },

                    id: 'id'
                };


             var dataAdapter = new $.jqx.dataAdapter(source, {loadError: function (xhr, status, error) {

                        }
             });

$("#jqxgrid").jqxGrid(
        {

            width: 800,
            source: dataAdapter,
            pageable: true,

            autoheight: true,

            columns: [
              { text: 'Period Name', datafield: 'periodname', width: 200 },
              { text: 'Start Date', datafield: 'startdate', width: 200 },
              { text: 'End Date', datafield: 'enddate', width: 200 },
              { text: 'Active', datafield: 'isactive', width: 200 }
            ]
        });

        $("#addrowbutton").jqxButton({ theme: theme });
        $("#deleterowbutton").jqxButton({ theme: theme });
        $("#updaterowbutton").jqxButton({ theme: theme });

        // initialize jqxGrid
               // });
    });
    </script>

控制器

 @Controller
 @RequestMapping(value="/account")
 public class AccountsController {
@Autowired
private AccountService accountService;
@Autowired
private AccountDAO accountDao;

 @RequestMapping(value="/list",method = RequestMethod.GET,produces="application/json")
 @ResponseBody
 public Map<String, Object> getAccounts(Map<String, Object> map) {

    map.put("all_item_issue_headers", accountDao.getAccounts());
    System.out.println(map);
    return map;

}
}

等待你的回复..谢谢

1 个答案:

答案 0 :(得分:3)

响应将是一个json。关键是all_item_issue_headers

  var response = yourJson; // this is the map

  var array = yourJson[all_item_issue_headers]; // this is an array