CodeFluent エンティティ (www.softfluent.com) で生成された MVC ソリューションで Kendo UI グリッド コントロールを使用した人はいますか? グリッドが AJAX 処理に必要とする JSON 結果を返そうとする障害に達しました。より経験豊富な開発者がこれを克服したかどうか疑問に思っています。
ありがとう。
CodeFluent エンティティ (www.softfluent.com) で生成された MVC ソリューションで Kendo UI グリッド コントロールを使用した人はいますか? グリッドが AJAX 処理に必要とする JSON 結果を返そうとする障害に達しました。より経験豊富な開発者がこれを克服したかどうか疑問に思っています。
ありがとう。
この投稿は古いですが、障害にぶつかっている他の人のために、Telerik の ASP.NET MVC Grid (Kendo UI Grid とほぼ同じです) を CodeFluent で動作させる方法を以下に示します。
名前空間をインポートします。
using CodeFluent.Runtime.Utilities;
using Kendo.Mvc.UI;
using Kendo.Mvc.Extensions;
...
次に、読み取りメソッドで次のものが必要になります。
サンプルコードは次のとおりです。
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" メソッドを呼び出すようにテレリック グリッドをセットアップする必要があります。