Model view controller 剑道UI MVC和CodeFluent实体

Model view controller 剑道UI MVC和CodeFluent实体,model-view-controller,codefluent,Model View Controller,Codefluent,是否有人将Kendo UI网格控件与CodeFluent entities(www.softfluent.com)生成的MVC解决方案一起使用?我在尝试返回网格处理AJAX所需的JSON结果时遇到了一个障碍,我想知道是否有更有经验的开发人员能够克服这个问题 谢谢。这篇文章很老了,但对于遇到障碍的其他人来说,我是如何让Telerik的ASP.NET MVC网格(相当于Kendo UI网格)在遇到一些困难后与CodeFluent一起工作的 导入名称空间: using CodeFluent.Runti

是否有人将Kendo UI网格控件与CodeFluent entities(www.softfluent.com)生成的MVC解决方案一起使用?我在尝试返回网格处理AJAX所需的JSON结果时遇到了一个障碍,我想知道是否有更有经验的开发人员能够克服这个问题


谢谢。

这篇文章很老了,但对于遇到障碍的其他人来说,我是如何让Telerik的ASP.NET MVC网格(相当于Kendo UI网格)在遇到一些困难后与CodeFluent一起工作的

导入名称空间:

using CodeFluent.Runtime.Utilities;
using Kendo.Mvc.UI;
using Kendo.Mvc.Extensions;
...
然后,在read方法中,您现在需要:

  • 将CodeFluent对象集合加载到列表中
  • 将CodeFluent对象集合转换为kendo数据源
  • 使用CodeFluent序列化程序将结果数据源转换为JSON。其他人似乎在将CodeFluent对象转换为JSON时存在各种问题,包括不能正确处理循环引用
  • 以下是示例代码:

    public ActionResult ReadForGrid([DataSourceRequest]DataSourceRequest request)
    {
        //Convert CodeFluent collection of objects to a list.
        List<MyCodeFluentModel> CFECollectionList = new List<MyCodeFluentModel>();
        foreach (MyCodeFluentModel aCodeFluentModel in MyCodeFluentModelCollection.LoadAll())
        {
            CFECollectionList.Add(new MyCodeFluentModel(fileMetaData));
        }
    
        //Convert the list to a DataSourceResult
        //Which is a formatted object suitable to be returned to the grid.
        DataSourceResult dataSourceResult = CFECollectionList.ToDataSourceResult(request);
    
        //Convert the DataSourceResult to JSON, and return it.
        return ConvertToJsonResponse(dataSourceResult);
    }
    
    public static ContentResult ConvertToJsonResponse(object obj)
    {
        string json = JsonUtilities.Serialize(obj);
        return PrepareJson(json);
    }
    public static ContentResult PrepareJson(string json)
    {
        ContentResult content = new ContentResult();
        content.Content = json;
        content.ContentType = "application/json";
    
        return content;
    }
    
    public ActionResult ReadForGrid([DataSourceRequest]DataSourceRequest请求)
    {
    //将对象集合转换为列表。
    List CFECollectionList=新列表();
    foreach(MyCodeFluentModelCollection.LoadAll()中的MyCodeFluentModel aCodeFluentModel)
    {
    添加(新的MyCodeFluentModel(fileMetaData));
    }
    //将列表转换为DataSourceResult
    //这是一个适合返回到网格的格式化对象。
    DataSourceResult DataSourceResult=CFECollectionList.ToDataSourceResult(请求);
    //将DataSourceResult转换为JSON,并返回它。
    返回ConvertToJsonResponse(dataSourceResult);
    }
    公共静态ContentResult ConvertToJsonResponse(对象obj)
    {
    字符串json=JsonUtilities.Serialize(obj);
    返回PrepareJson(json);
    }
    公共静态ContentResult PrepareJson(字符串json)
    {
    ContentResult content=新ContentResult();
    content.content=json;
    content.ContentType=“应用程序/json”;
    返回内容;
    }
    

    现在,您只需要设置telerik网格来调用“ReadForGrid”方法。

    您能更具体一点并显示一些代码吗?有什么问题吗?JSON是如何构造的?事实上,问题在于CodeFluent实体没有利用实体框架,因此试图使用Kendo DataRequest和ToDataSourceResult来启用AJAX编辑是行不通的——至少是开箱即用的。事实上,CodeFluent实体与实体框架没有任何关系(除了“实体”一词之外)但这并不意味着它不能与剑道UI MVC一起工作。请发布更具体的问题(您也可以使用供应商论坛)