リポジトリからデータを取得し、Ajax を使用して Bootgrid を介してビューにグリッドを設定する ApiController を作成することができました。これは、Api のアクションに送信されるリクエスト データの例です。こちらのドキュメントで指定されています([POST ボディ リクエスト] タブを探します)。
current=1&rowCount=10&sort[sender]=asc&searchPhrase=&id=b0df282a-0d67-40e5-8558-c9e93b7befed
URL の例を次に示します。
http://localhost/api/SomeController?current=1&rowCount=10&sort%5BName%5D=asc&searchPhrase=&id=b0df282a-0d67-40e5-8558-c9e93b7befed
応答として返す必要があるデータを処理し、データを並べ替える (配列であるため) 2 つのヘルパー クラスを作成しました。
public class SortData
{
public string Field { get; set; } // FIeld Name
public string Type { get; set; } // ASC or DESC
}
public class BootgridResponseData<T> where T: class
{
public int current { get; set; } // current page
public int rowCount { get; set; } // rows per page
public IEnumerable<T> rows { get; set; } // items
public int total { get; set; } // total rows for whole query
}
したがって、私の行動は次のとおりです。
public BootgridResponseData<SomeViewModel> Get(int current, int rowCount, List<SortData> sort, string searchPhrase, string id)
{
// get items and return a bootgrid response data with them...
}
メソッドが呼び出され、常に null である sort を除いて、すべてのパラメーターが適切にデータを受け取ります。
これにはどのような種類のパラメーターを期待する必要がありますか? 私も入れようとしましたobject
が、とにかくnullになります。