我正在尝试使用本地数据设置kendo mvc ui网格,并使其可以按照此演示Binding to local data进行排序 . 但是网格不显示数据,如果我挂起onDataBound事件,那里的数据是未定义的 . 如果我在视图上注释掉DataSource设置,则数据首先会填充,但在任何列上执行排序后会消失 . 我使用的是Kendo UI版本:"2013.3.1119",asp.net mvc 4.请指教 . 谢谢 .

查看

@model TestViewModel
@(Html.Kendo().Grid(Model.TestList)
    .Name("grid2")
    .Columns(columns =>
    {
        columns.Bound( p => p.Id ).Title( "ID" );
        columns.Bound( p => p.Name ).Title("Product Name");
    })
    .Pageable()
    .Sortable()
    .Scrollable(scr=>scr.Height(430)) 
    .Filterable()    
    .DataSource(dataSource => dataSource        
        .Ajax()
        .PageSize(20)
        .ServerOperation(false))
)

控制器和型号

public class TestController : Controller
{
    //
    // GET: /Test/
    public ActionResult Index()
    {
        var mdl = new TestViewModel();
        mdl.TestList = Test().ToList();

        return View(mdl);
    }

    public IEnumerable<TestMe> Test()
    {
        var lst = new List<TestMe>();
        for( int i = 0; i < 5; i++ )
        {
            lst.Add( new TestMe
            {
                Id = i,
                Name = i.ToString(),
            } );
        }
        return lst;
    }
}

public class TestViewModel
{
    public List<TestMe> TestList { get; set; }

    public TestViewModel()
    {
        TestList = new List<TestMe>();
    }
}

public class TestMe
{
    public int Id { get; set; }
    public string Name { get; set; }
}