$(“#grid”)。数据(“kendoGrid”)在MVC Razor的$ .getJSON成功方法中未定义

时间:2015-02-03 20:11:49

标签: kendo-ui kendo-grid kendo-asp.net-mvc

我有以下Kendo.mvc网格

@Html.HiddenFor(model => model.BarCode)
                                <div style="padding-left:10%;padding-top:2%">
                                    @(Html.Kendo().Grid(Model.BarCodes)
                                .Name("grid")
                                .Columns(columns =>
                                {
                                    columns.Bound(e => e.DocumentSetName)
                                    .Width(100)
                                    .Title("Reference No");
                                    columns.Bound(e => e.ScannedDate)
                                    .Title("Scanning Date")
                                    .Width(100);

                                })
                                .Sortable()
                                .Pageable()
                                .DataSource(dataSource => dataSource
                                .Ajax()
                                .PageSize(3)
                                    //.Read(read => read.Action("SearchUnregisteredIncomings", "Correspondence").Data("getSearchCriteria"))
                                )
                                .ClientDetailTemplateId("template")
                                    )

这是我所做的ajax调用

 $.getJSON('@Url.Action("Search")', {ReferenceNumber:'123'
    }, function (data, status) {
         var grid = $("#grid").data("kendoGrid");
        grid.dataSource.data(data);
        grid.refresh();

        $("#loading").stop().fadeOut('fast');
    });

网格变量未定义。 以下是_Layout.cshtml文件中加载的.js文件和脚本的名称和顺序。

 <script src="/Scripts/modernizr-2.6.2.js"></script>
 <script src="/Scripts/kendo/jquery.min.js"></script>
 <script src="/Scripts/spin.js"></script>
 <script src="/Scripts/kendo/kendo.all.min.js"></script>
 <script src="/Scripts/bootstrap-multiselect.js"></script>
 <script src="/Scripts/kendo/kendo.aspnetmvc.min.js"></script>
 <script src="/Scripts/chosen.jquery.min.js"></script>

以下脚本在@RenderBody()部分之后但在</body>标记

之前加载
<script src="/Scripts/jquery-1.10.2.js"></script>
<script src="/Scripts/jquery-1.8.2.js"></script>
<script src="/Scripts/bootstrap.js"></script>
<script src="/Scripts/respond.js"></script>
<script src="/Scripts/spcontext.js"></script>
<script src="/Content/vendors/jquery-1.9.1.js"></script>
<script src="/Content/vendors/modernizr-2.6.2-respond-1.1.0.min.js">/script>
<script src="/Content/vendors/jquery.uniform.min.js"></script>
<script src="/Content/vendors/chosen.jquery.min.js"></script>
<script src="/Content/vendors/bootstrap-datepicker.js"></script>
<script src="/Content/vendors/wysiwyg/wysihtml5-0.3.0.js"></script>
<script src="/Content/vendors/wysiwyg/bootstrap-wysihtml5.js"></script>
<script src="/Content/vendors/wizard/jquery.bootstrap.wizard.min.js"></script>
<script src="/Content/assets/treeview.js"></script>
<script src="/Content/assets/form-validation.js"></script>

    <script>
        $(function () {
            $(".datepicker").datepicker();
            $(".uniform_on").uniform();
            $(".chzn-select").chosen();
            $('.textarea').wysihtml5();
        });
        (function (window, undefined) {      
            var $ = window.jQuery;
            var document = window.document;    

            $(document).ready(function () {                    
               //some code here
            });
        })(window);

我认为这个问题是由于.js文件的顺序造成的,但无法解决。

0 个答案:

没有答案