cstoliuyong
cstoliuyong
2013-06-26 17:25

datagrid 对json数据的读取

  • jquery

jsp中代码
[code="html"]



Basic DataGrid - jQuery EasyUI Demo


<script type="text/javascript" src="easeUI/jquery.min.js"></script>
<script type="text/javascript" src="easeUI/jquery.easyui.min.js"></script>

<script type="text/javascript">
    $(document).ready(function(){
        $('#datagrid').datagrid({ 
            toolbar:'#tb',
            url : 'lawService.action',
            title:'Load Data',
            columns : [ [ {  
                   field : 'id',
                   width : '100',
                   checkbox:true
               },{  
                   field : 'time',
                   title : '标题',  
                   width : '100',
                   align : 'center'
               }, {  
                   field : 'title',
                   title : '时间',  
                   width : '100',
                   align : 'center',
               }] ],
            idField:'id',
            loadMsg:'Processing, please wait …',
            pagination:true
        });
    });
</script>



Basic DataGrid




The DataGrid is created from markup, no JavaScript code needed.




<div id="tb" style="padding:5px;height:auto">
    <div style="margin-bottom:5px">
        <a href="#" class="easyui-linkbutton" iconCls="icon-add" plain="true">add</a>
        <a href="#" class="easyui-linkbutton" iconCls="icon-edit" plain="true">edit</a>
        <a href="#" class="easyui-linkbutton" iconCls="icon-cut" plain="true">delete</a>
    </div>
    <div>
        Date From: <input class="easyui-datebox" style="width:80px">
        To: <input class="easyui-datebox" style="width:80px">
        <a href="#" class="easyui-linkbutton" iconCls="icon-search">Search</a>
    </div>
</div>



[/code]
经过测试该datagrid中url的action的请求返回值是:{"total":3,"row":[{"id":"1","time":"时间time","title":"法律title"},{"id":"2","time":"时间1time","title":"法律1title"},{"id":"3","time":"时间2time","title":"法律2title"}]}
该返回值和官网中自定义的json数据格式一样。
question:在datagrid中的columns为什么不能加载json的数据??求教!!!

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

1条回答