读取json文件

//读取json文件将数据现在列表中
①var url=document.location.host;
document.write("<script language='javascript' src='http://"+url+"/gm/common/js/gm/xh/gameData/item_json.js'></script>");
或者
②document.write("<script language='javascript' src='../../common/js/gm/xh/gameData/item_json.js'></script");
$(document).ready(function(){
      $('#ss').datagrid({
          title:'当前位置:游戏数据——>道具流水',
          url:'./list.do',    //定义这个数据表格的数据来源
          method:"post", 
          rownumbers:true,    //显示序列号
          singleSelect:true,  //只允许选择一行
          striped:true,       //斑马线
          loadMsg:'正在加载中,请稍等...',
          multiSort:true,
          sortOrder:'asc' ,
          pageList:[20,30,40,60], //页面导航展示的页码
          fitColumns:true, 
          columns:[[  
            {checkbox:true},
            {field:'orderNo',title: '物品名称',width: 140,align:'center','formatter':function(value,row,index){
                  var text = '';
                  for(var i=0;i<json.length;i++){
                      if(json[i].id == value){
                          text = json[i].text;
                          break;
                      }
                  }
                  return text;       
              }}, 
            {field:'updateTime ',title:'时间日期',width:300,align:'center'}
          ]],  
          //鼠标悬浮事件
          onLoadSuccess:function(){
              $(".datagrid-row").mouseover(function(){  
                  var updateTime = $(this).children("td").eq(2); //eq(2):列数
                  updateTime.attr("title",$(this).children("td").eq(3).text());//eq(3)显示位置
              });  
            },
            pagination:true,
           toolbar:'#toolbar'});
      var pager = $('#ss').datagrid('getPager');  
      pager.pagination({  
            showPageList:true,  
            beforePageText: '第',//页数文本框前显示的汉字  
            afterPageText: '页    共 {pages} 页',  
            displayMsg: '当前显示 {from} - {to} 条记录   共 {total} 条记录'
        });     
}); 
//item_json.js 文件
var actionJson = [{
    "id":101,
    "text":"地上捡的"
},{
    "id":102,
    "text":"邮件附件"
},{
    "id":103,
    "text":"商城购买"
},{
    "id":104,
    "text":"接任务给予"
},{
    "id":105,
    "text":"任务奖励"
},{
    "id":106,
    "text":"日常任务奖励"
},{
    "id":107,
    "text":"采集、打怪收集获得"
},{
    "id":108,
    "text":"线上活动(首冲、冲级活动等)"
},{
    "id":109,
    "text":"在线奖励"
},{
    "id":110,
    "text":"世界BOSS"
}]

猜你喜欢

转载自nice2230.iteye.com/blog/2237869