搜索框。剑道UI。格

时间:2017-01-26 13:27:13

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

我有一些问题。我希望通过它的id找到对象。通过id找到人的方法,我已经测试过了!控制器中的动作方法太有效,但在剑道ui网格中不呈现数据。 我的剑道网格看起来像这样:

@(Html.Kendo().Grid<PersonViewModel>()
             .Name("SearchPersonGrid")
             .ToolBar(toolBar =>
             {
             toolBar.Template(@<text>
                <div class="toolbar">
                    <div class="row">
                        <div class="col-md-4">
                            <div class="input-group">
                                <span class="input-group-addon"><span class="glyphicon glyphicon-search" aria-hidden="true"></span></span>
                                <input type="text" class="form-control" id='searchBox'>
                                <span class="input-group-btn">
                                    <button class="btn btn-default" type="button" id="test"><span class="glyphicon glyphicon-refresh" aria-hidden="true"></span></button>
                                </span>
                            </div>
                        </div>
                    </div>
                </div>
            </text>);
             })
                     .Columns(columns =>
                     {
                         columns.Bound(column => column.Id);
                         columns.Bound(column => column.Name);
                         columns.Bound(column => column.Surname);
                         columns.Bound(column => column.Age);                                       
                     })
                     .DataSource(dataSource => dataSource
                     .Ajax()                                    
                     .Read(read => read.Action("FindPersonById", "PersonSettings"))                                     
                     .Selectable(selectTable => selectTable
                     .Mode(GridSelectionMode.Single)
                     .Type(GridSelectionType.Row))
                     .Editable(editTable => editTable.Mode(GridEditMode.InLine))
                     .Pageable()
                     .Sortable()
                     )

我的脚本看起来像这样:

    $(document).ready(function () {  
    $("#searchBox").keypress(function () {
        searchClick();
    });            
});

function searchClick() {
    var searchBox = $("#searchBox").val();
    var data = {
        "personId": searchBox
    };
    var urlPath = '@Url.Action("FindPersonById", "PersonSettings")';
    $.ajax({
        type: "POST",
        url: urlPath,
        data: JSON.stringify(data),
        contentType: "application/json; charset=utf-8",
        dataType: "html",
        success: function (jsonData) {
            var grid = $('#SearchEventGrid').data('kendoGrid').dataSource.data([]);
            $("SearchEventGrid").data('kendoGrid').DataSource.data(jsonData.Data);
        },
    });
}

调试器告诉我错误:$(“SearchEventGrid”)。data('kendoGrid')。DataSource.data(jsonData.Data); 未捕获的TypeError:无法读取未定义的属性“dataSource” 我想找到对象并填充网格!

0 个答案:

没有答案