2013-07-17 2 views
0

CodeFluent 엔티티 (www.softfluent.com)에서 검도 UI Grid 컨트롤을 사용하는 사람이 MVC 솔루션을 생성 했습니까? Grid가 AJAX 처리에 필요로하는 JSON 결과를 반환하려는로드 블록에 도달했습니다. 경험 많은 개발자가이 문제를 극복 할 수 있었는지 궁금합니다.검도 UI MVC 및 CodeFluent 엔티티

감사합니다.

+0

좀 더 구체적인 코드를 보여 주시겠습니까? JSON은 어떻게 구성되어 있습니까? –

+0

실제로 CodeFluent Entities는 Kendo DataRequest 및 ToDataSourceResult를 사용하여 AJAX 편집이 작동하지 않도록 Entity Framework를 사용하지 않습니다. – user2589758

+1

실제로 CodeFluent Entities는 Entity Framework와는 관계가 없지만 ("엔터티"단어 제외) Kendo UI MVC에서 작동하지 않는다는 의미는 아닙니다. 보다 구체적인 질문을 게시하십시오 (공급 업체 포럼을 사용할 수도 있습니다). –

답변

1

이 게시물은 오래되었지만 도로 블록을 밟은 다른 사람들을 위해 Telerik의 ASP.NET MVC Grid (꽤 많은 Kendo UI Grid)가 CodeFluent와 함께 몇 가지 어려움을 겪은 다음 여기에 나와 있습니다.

가져 오기 네임 스페이스 :

using CodeFluent.Runtime.Utilities; 
using Kendo.Mvc.UI; 
using Kendo.Mvc.Extensions; 
... 

그런 다음 읽기 방법, 당신은 지금 필요

  1. 이 목록에, 당신의 CodeFluent 개체 모음을로드합니다.
  2. CodeFluent 객체 컬렉션을 검도 데이터 소스로 변환합니다.
  3. 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; 
} 

그리고 지금 당신은 단지 "ReadForGrid"메소드를 호출하는 설정에 telerik 그리드가 필요합니다.