我正在尝试通过使用自定义列表而不使用按钮单击中的任何数据库来显示 kendo Ui 网格中的详细信息,但我未能在网格中显示详细信息,为此我已经这样做了..
这是我的模型
namespace KendoPratapSampleMVCApp.Models
{
public class SampleGrids
{
public List<Sample> samples;
}
public class Sample
{
public string SampleDescription { get; set; }
public string SampleCode {get; set;}
public string SampleItems { get; set; }
}
}
这是控制器(这里我正在调用事件getsamples()
内部的方法PostValues
(这是按钮单击事件))
namespace KendoPratapSampleMVCApp.Controllers
{
public class SearchResultsDisplayController : Controller
{
//
// GET: /SearchResultsDisplay/
public ActionResult Index()
{
return View();
}
public static IEnumerable<Sample> GetSamples()
{
List<Sample> sampleAdd = new List<Sample>();
Sample s12 = new Sample();
s12.SampleCode = "123se";
s12.SampleDescription = "GOOD";
s12.SampleItems = "newone";
Sample s2 = new Sample();
s2.SampleCode = "234se";
s2.SampleDescription = "Average";
s2.SampleItems = "oldone";
sampleAdd.Add(s12);
sampleAdd.Add(s2);
return sampleAdd;
}
[HttpPost]
public ActionResult PostValues(Sample model)
{
return View("Index",GetSamples());
}
public ActionResult Orders_Read([DataSourceRequest]DataSourceRequest request)
{
return Json(GetSamples().ToDataSourceResult(request));
}
}
}
这是我的观点(这里我使用 jquery 绑定)
@Scripts.Render("~/bundles/jquery")
<script type ="text/javascript">
$('#Submit1').click(function () {
alert('1'); // dint get this alert when I click on submit button
$('#grid12').data('kendoGrid').dataSource.read();
// $('#grid12').css("display", "block");
});
</script>
@model IEnumerable<KendoPratapSampleMVCApp.Models.Sample>
@{
ViewBag.Title = "Index";
}
<h2>Index</h2>
@using (Html.BeginForm("PostValues", "SearchResultsDisplay", FormMethod.Post))
{
<input id="Submit1" type="submit" value="SubmitValue" />
@(Html.Kendo().Grid<KendoPratapSampleMVCApp.Models.Sample>()
.Name("grid12")
.Columns(columns => {
columns.Bound(p => p.SampleDescription).Filterable(false).Width(100);
columns.Bound(p => p.SampleCode).Filterable(false).Width(100);
columns.Bound(p => p.SampleItems).Filterable(false).Width(100);
})
.Pageable()
.Sortable()
.Scrollable()
.AutoBind(false) // here I am disabling automatic binding at page load
.Filterable()
.HtmlAttributes(new { style = "height:430px;" })
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(20)
.Read(read => read.Action("Orders_Read", "SearchResultsDisplay"))
)
)
}
当我们提交按钮时我无法绑定数据任何建议和任何想法都会非常感谢我......非常感谢......