猿问

json应用于asp.net mvc求解?

$('#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'的值,那位高手帮忙解决下,谢谢了!

泛舟湖上清波郎朗
浏览 379回答 1
1回答

临摹微笑

路径问题吧,mvc重写了URL的
随时随地看视频慕课网APP
我要回答