他にも同様の問題があり、同様の問題を抱えていると同時に重複してマークしないでください。剣道UIがボタンクリックでデータを読み込まない
私はボタンクリックで剣道グリッドを読み込もうとしていますが、私にとっては効果がないようです。私は下の私のファイルを添付しています:
KendoData.cshtml
<div id="grid">
@(Html.Kendo().Grid(<MvcApplication1.Models.Customer)
.Name("AjaxGrid")
.AutoBind(false)
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(20)
.Read(read => read.Action("KendoDataAjaxHandle", "Default1Controller"))
)
.Columns(columns =>
{
//Create a column bound to the ProductID property.
columns.Bound(customer => customer.CustomerAltID);
//Create a column bound to the ProductName property.
columns.Bound(customer => customer.CustomerName);
//Create a column bound to the UnitsInStock property.
columns.Bound(customer => customer.Gender);
})
.Pageable() //Enable the paging.
.Sortable() //Enable the sorting.
.Groupable()
)
</div>
<style>
#AjaxGrid {
display: none;
}
</style>
<button class="btn btn-warning grid" type="button">Load Ajax KendoData</button>
jQueryの
$('button.grid').click(function() {
$("#AjaxGrid").data("kendoGrid").dataSource.read();
$("#AjaxGrid").css("display", "block");
});
コントローラ
public class Default1Controller : Controller
{
//
// GET: /Default1/
private Sales_DW db= new Sales_DW();
public ActionResult KendoData()
{
return View();
}
public ActionResult KendoDataAjaxHandle([DataSourceRequest]DataSourceRequest request)
{
IQueryable<Customer> products = db.Customers;
DataSourceResult result = products.ToDataSourceResult(request);
return Json(result, JsonRequestBehavior.AllowGet);
}
}
ボタンをクリックすると、コンソールにCannot read property dataSource of undefined
エラーが表示されます。 誰かが私がここで間違ったことを教えてもらえますか?前もって感謝します。
ありがとうRajshekhar。これを試してみましたが、それでも同じエラーです。 –
@AakashThakur私はここで小さな更新をしました.Grid() 'この構文でチェックしてください。 –
まだ同じエラーが発生しています。 –