どのように実際にNextPage、PreviousPage操作をトリガーしているのか分かりません...
MVCカスタムデータソース設定を使用すると、スキーマ設定のような多くのオプションにアクセスできます。以下のために((グリッドに与えること)
{ items: [. . . ], nextPage: 'J23jeg9e93', previousPage: 'oqow0r93285' }
と項目を抽出し、NEXTPAGE、previousPage値: http://docs.telerik.com/aspnet-mvc/getting-started/custom-datasource
スキーマの設定は、カスタム結果の形式を取ることができます解析機能を追加することができますあなたは次の読み取り要求に渡すために保存する必要があります)。例えば
:
サンプルグリッド:
@(Html.Kendo().Grid<TelerikMvcApp4.Models.GridViewModel>()
.Name("grid")
.DataSource(ds => ds
.Custom()
.Batch(true)
.Schema(schema => schema
.Parse(@<text>parseData</text>)
)
.Transport(transport => transport
.Read(read => read.Action("Grid_Read", "Home").Type(HttpVerbs.Post).Data("readData"))
)
.PageSize(1)
.ServerPaging(true)
)
.Pageable()
)
サンプルparseData及びて、readDataのjavascript:
<script>
var nextPage,
previousPage;
function readData() {
// Return the "extra" data that should be posted with each grid read request, which is the nextPage/previousPage we were given in the previous request respsonse.
return {
nextPage: nextPage,
previousPage: previousPage
};
}
function parseData(data) {
// Parse the response from the server as it isn't in the typical format expected by the grid.
// Extract your nextPage/previousPage, store it somewhere so they can be added to the next grid request.
nextPage = data.nextPage;
previousPage = data.previousPage;
// Return the actual data that should be displayed in the grid.
return data.items;
}
</script>
サンプルグリッドは、アクションを読み取る:
[HttpPost]
public ActionResult Grid_Read([DataSourceRequest] DataSourceRequest request, string nextPage, string previousPage)
{
// "Fetch" the data, presumably doing something with nextPage and previousPage...
var items = new List<GridViewModel>()
{
new GridViewModel() { name = "bob", age = 23},
new GridViewModel() { name = "jim", age = 43},
};
// Determine what the new nextPage, previousPage should be...
var newNextPage = "J23jeg9e93";
var newPreviousPage = "oqow0r93285";
return Json(new
{
items = items,
nextPage = newNextPage,
previousPage = newPreviousPage
});
}
これはありません共同頑丈なソリューションですが、それは実行可能にでき、少なくともあなたを可能な方向に向けるでしょう。
剣道がそれを解析する前に、どこかにあなたのデータの 'nextPage'と' previousPage'情報を追加する必要がありますか? – DontVoteMeDown
'Read()'コマンドはグリッドに入る '[{name: 'bob'、age:23}、{name: 'jim'、age:43} ...]'のようなデータを返します。しかし、次のページトークンと前のページトークンを持つメタデータを含める必要があります。しかし、私はリストを返すだけなので、私はそれを含めることはできません。 – NibblyPig
残念なことにidkは非常によく剣道Asp.netのフレームワークですが、Javascriptではこれを行うには2つの可能な方法があると思います:あなたのメタデータを 'dataSource.schema.parse'イベントに追加してください。または 'dataSource.transport。関数を使用して独自のリクエストを作成し、データをウィジェットに渡すことができます。そこにメタデータを追加することができます。しかし、それが剣道Asp.Netでできるかどうかはわかりません。私はそれが可能だと信じています。 – DontVoteMeDown