首页 新闻 搜索 专区 学院

json应用于asp.net mvc求解?

0
[已解决问题] 解决于 2011-02-23 10:42

$('#test').datagrid({
                title: 'My Title',
                iconCls: 'icon-save',
                width: 600,
                height: 350,
                nowrap: false,
                striped: true,
                collapsible: true,
                url: '../../Json/datagrid_data.json',
                sortName: 'code',
                sortOrder: 'desc',
                remoteSort: false,
                idField: 'code',
                frozenColumns: [[
                 { field: 'ck', checkbox: true },
                 { title: 'code', field: 'code', width: 50, sortable: true }
    ]],
                columns: [[
           { field: 'name', title: 'Name', width: 90 },
     { field: 'addr', title: 'Address', width: 90, sortable: true,
         sorter: function (a, b) {
             return (a > b ? 1 : -1);
         }
     },
     { field: 'col4', title: 'Col41', width: 100 },
     { field: 'opt', title: 'Operation', width: 70, align: 'center',
         formatter: function (value, rec) {
             return '<span style="color:red">Edit Delete</span>';
         }
     }
    ]],
                pagination: true,
                rownumbers: true,
                toolbar: [{
                    id: 'btnadd',
                    text: 'Add',
                    iconCls: 'icon-add',
                    handler: function () {
                        $('#btnsave').linkbutton('enable');
                        alert('add')
                    }
                }, {
                    id: 'btncut',
                    text: 'Cut',
                    iconCls: 'icon-cut',
                    handler: function () {
                        $('#btnsave').linkbutton('enable');
                        alert('cut')
                    }
                }, '-', {
                    id: 'btnsave',
                    text: 'Save',
                    disabled: true,
                    iconCls: 'icon-save',
                    handler: function () {
                        $('#btnsave').linkbutton('disable');
                        alert('save')
                    }
                }]
            });
            var p = $('#test').datagrid('getPager');
            if (p) {
                $(p).pagination({
                    onBeforeRefresh: function () {
                        alert('before refresh');
                    }
                });
            }
        });

 

上面一段JS代码,为什么放在MVC里就不能获取'datagrid_data.json'里的值,而把它放到HTML里又能获取'datagrid_data.json'的值,那位高手帮忙解决下,谢谢了!

lhz_belen的主页 lhz_belen | 初学一级 | 园豆:185
提问于:2010-10-11 10:01
< >
分享
最佳答案
0

路径问题吧,mvc重写了URL的

吕飞 | 菜鸟二级 |园豆:280 | 2010-10-24 09:51
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册