如何通过从 kendo 日期选择器传递日期来将数据绑定到 kendo 网格?
How to Bind Data to kendo grid by passing date from kendo datepicker?
我是 Kendo UI 的新手,我有一个 kendo DatePicker 和一个 Kendo GridView。根据数据从 DatePicker 选择日期后,应绑定到 Kendo GridView。我将 jquery 与 Ajax 一起使用,我的 jquery 函数是
List<MDA.AppEntities.Orders.OrderList> objConsults = new List<MDA.AppEntities.Orders.OrderList>();
objConsults = DataFacade.Operations.GetCustomerOrderDetailsByCustomerID(Patientid,startDate,endDate );
return new PrimeJsonResult { MaxJsonLength = int.MaxValue, JsonRequestBehavior = JsonRequestBehavior.AllowGet, Data = new GridModel<MDA.AppEntities.Orders.OrderList> { Data = objConsults } };
它进入了success: function(data)
,但没有执行内部代码并跳回到$.ajax(
),我不明白为什么。
@(Html.Kendo().Grid<MDA.AppEntities.Orders.OrderList>(Model.OrderList)
.Name("GridOrders")
.PrefixUrlParameters(false)
.Columns(col =>
{
col.Bound(o => o.Ord_ID).Title("Event ID").Width("10%");
col.Bound(o => o.Ord_Date).Title("Event Date").Format("{0:MM/dd/yyyy}").Width("10%");
col.Bound(o => o.Status).ClientTemplate("# if (EventType == 'eConsult') { # " + "<strong> #: EventConsultStatus #</strong> "
+ " # } else if (OS_ID == " + (int)MDA.AppConstants.OrderStatus.AllOrderStatus.LocalPickupInScriptSureQueue + " || OS_ID == "
+ (int)MDA.AppConstants.OrderStatus.AllOrderStatus.LocalPickupProcessing + " || OS_ID == " + (int)MDA.AppConstants.OrderStatus.AllOrderStatus.LocalPickupPending
+ " || OS_ID == " + (int)MDA.AppConstants.OrderStatus.AllOrderStatus.LocalPickupEnteredWithErrors + " || OS_ID == "
+ (int)MDA.AppConstants.OrderStatus.AllOrderStatus.LocalPickupScriptSureTimeWait + "){ # " + " <p> Rx Approved </p> " + " # } else if (OS_ID == "
+ (int)MDA.AppConstants.OrderStatus.AllOrderStatus.LocalPickupEntered + " || OS_ID == " + (int)MDA.AppConstants.OrderStatus.AllOrderStatus.PickedFromLocalPharmacy
+ ") { # " + " <p> LPU Complete </p>" + " # } else { # " + "<strong> #: OS_Desc # </strong>" + " # } #").Title("Status").Width("12%");
col.Bound(o => o.Comment).Title("Details").Width("20%");
col.Bound(o => o.TotalPrice).Title("Rx Cost").Format("$ " + "{0:F2}").Width("8%");
col.Bound(o => o.EventConsultStatusID).ClientTemplate(" # if((OS_ID==" + (int)MDA.AppConstants.OrderStatus.AllOrderStatus.OrderSubmitted
+ "|| OS_ID ==" + (int)MDA.AppConstants.OrderStatus.AllOrderStatus.ConsultationStarted
+ ")&& (EventConsultStatusID==" + (int)MDA.AppConstants.ConstantValues.ConsultationStatus.SUBMIT
+ " || EventConsultStatusID==" + (int)MDA.AppConstants.ConstantValues.ConsultationStatus.START
+ ")) {# " + @Html.ActionLink(String.IsNullOrEmpty("EditConsultation") ? "-" : "EditConsultationlink", "CreateConsultation", new { @CustID = "#=Cust_ID#", @IsEdit = "#=Ord_ID#" }, getHtmlAttributesForActionLink("EditConsultation")) + "#} else if ( EventConsultStatusID == "
+ (int)MDA.AppConstants.ConstantValues.ConsultationStatus.WRITTEN + ") {# <a href= " + Url.Action("ReviewConsultation", "Customer", new { id = "#=Ord_ID#" }) + " > view consult <p> See Doctor Notes and place Order if Prescription Written </p> </a> #} else if (EventConsultStatusID == "
+ (int)MDA.AppConstants.ConstantValues.ConsultationStatus.PENDING + ") {# <a href=" + Url.Action("ReviewConsultation", "Customer", new { id = "#Ord_ID#" })
+ "> view consult <p> See Doctor Notes and Respond </p> </a> #} else if (Eligible_ReFill && (OS_ID == 35 || OS_ID == 41)){ # <p> Eligible for Re-fill </p> <span > Please click on View Consult Link to see Refill link </span> #} else if (Eligible_ReOrder && (OS_ID == 35 || OS_ID == 41) && EventTypeID == 1) {# <p> Eligible for Re-Order </p> <span > Please click on View Consult Link to see ReOrder link </span> #} else if (EventType == 'eConsult' || EventType == 'TeleConsult') {# <a href="
+ Url.Action("ReviewConsultation", "Customer", new { id = "#=Ord_ID#" }) + "> view consult </a> #} else {# <a href=" + Url.Action("OrderDetails", "Customer", new { id = "#=Ord_ID#" })
+ "> view consult </a> # } if (OS_ID ==" + (int)MDA.AppConstants.OrderStatus.AllOrderStatus.OrderShipped + " || OS_ID == " + (int)MDA.AppConstants.OrderStatus.AllOrderStatus.PickedFromLocalPharmacy + ") {# <a href='javascript:void(0);' onclick=javascript:CenterWindow(900,800,50,"
+ Url.Action("ViewReceipt", "Customer", new { id = "#=Ord_ID#" }) + ">);> View/Print Receipt </a> #} if (OS_ID != " + (int)MDA.AppConstants.OrderStatus.AllOrderStatus.OrderCanceled + ") {# <br /> <a href="
+ Url.Action("AttachReporToConsult", "Customer", new { OrderId = "#=Ord_ID#" }) + "> Attach Report </a> #} #").Title("Sample1").Width("25%");
})
.Resizable(resizing => resizing.Columns(true))
.Pageable(Page => Page.Refresh(true).PageSizes(true).PreviousNext(true))
.Filterable()
.Sortable()
.Scrollable()
.Groupable()
.Reorderable(reorder => reorder.Columns(true))
.DataSource(dataSource => dataSource.Ajax()
.Read(read => read.Action("_DemoDashBoard", "Customer", new { patientid = Model.CustomerID, startdate= Model.SearchStartDate, enddate=Model.SearchEndDate }))
.ServerOperation(false)
)
)
我认为您不需要 ajax 电话。试试这个,dataSource.read()
应该使用更新后的参数调用您的操作:
$("#showDate").click(function(){
var pid = $("#PatientID").val();
var dtStartDate = $("#startDate").val();
var dtEndDate = $("#endDate").val();
if(dtStartDate > dtEndDate) {
$("#spnshowDate").html("<html>From date should not be greater than To date</html>");
}
var grid = $("#gridOrders").data("kendoGrid");
grid.dataSource.read({ patientid: pid, startdate: dtStartDate, enddate: dtEndDate })
});
我是 Kendo UI 的新手,我有一个 kendo DatePicker 和一个 Kendo GridView。根据数据从 DatePicker 选择日期后,应绑定到 Kendo GridView。我将 jquery 与 Ajax 一起使用,我的 jquery 函数是
List<MDA.AppEntities.Orders.OrderList> objConsults = new List<MDA.AppEntities.Orders.OrderList>();
objConsults = DataFacade.Operations.GetCustomerOrderDetailsByCustomerID(Patientid,startDate,endDate );
return new PrimeJsonResult { MaxJsonLength = int.MaxValue, JsonRequestBehavior = JsonRequestBehavior.AllowGet, Data = new GridModel<MDA.AppEntities.Orders.OrderList> { Data = objConsults } };
它进入了success: function(data)
,但没有执行内部代码并跳回到$.ajax(
),我不明白为什么。
@(Html.Kendo().Grid<MDA.AppEntities.Orders.OrderList>(Model.OrderList)
.Name("GridOrders")
.PrefixUrlParameters(false)
.Columns(col =>
{
col.Bound(o => o.Ord_ID).Title("Event ID").Width("10%");
col.Bound(o => o.Ord_Date).Title("Event Date").Format("{0:MM/dd/yyyy}").Width("10%");
col.Bound(o => o.Status).ClientTemplate("# if (EventType == 'eConsult') { # " + "<strong> #: EventConsultStatus #</strong> "
+ " # } else if (OS_ID == " + (int)MDA.AppConstants.OrderStatus.AllOrderStatus.LocalPickupInScriptSureQueue + " || OS_ID == "
+ (int)MDA.AppConstants.OrderStatus.AllOrderStatus.LocalPickupProcessing + " || OS_ID == " + (int)MDA.AppConstants.OrderStatus.AllOrderStatus.LocalPickupPending
+ " || OS_ID == " + (int)MDA.AppConstants.OrderStatus.AllOrderStatus.LocalPickupEnteredWithErrors + " || OS_ID == "
+ (int)MDA.AppConstants.OrderStatus.AllOrderStatus.LocalPickupScriptSureTimeWait + "){ # " + " <p> Rx Approved </p> " + " # } else if (OS_ID == "
+ (int)MDA.AppConstants.OrderStatus.AllOrderStatus.LocalPickupEntered + " || OS_ID == " + (int)MDA.AppConstants.OrderStatus.AllOrderStatus.PickedFromLocalPharmacy
+ ") { # " + " <p> LPU Complete </p>" + " # } else { # " + "<strong> #: OS_Desc # </strong>" + " # } #").Title("Status").Width("12%");
col.Bound(o => o.Comment).Title("Details").Width("20%");
col.Bound(o => o.TotalPrice).Title("Rx Cost").Format("$ " + "{0:F2}").Width("8%");
col.Bound(o => o.EventConsultStatusID).ClientTemplate(" # if((OS_ID==" + (int)MDA.AppConstants.OrderStatus.AllOrderStatus.OrderSubmitted
+ "|| OS_ID ==" + (int)MDA.AppConstants.OrderStatus.AllOrderStatus.ConsultationStarted
+ ")&& (EventConsultStatusID==" + (int)MDA.AppConstants.ConstantValues.ConsultationStatus.SUBMIT
+ " || EventConsultStatusID==" + (int)MDA.AppConstants.ConstantValues.ConsultationStatus.START
+ ")) {# " + @Html.ActionLink(String.IsNullOrEmpty("EditConsultation") ? "-" : "EditConsultationlink", "CreateConsultation", new { @CustID = "#=Cust_ID#", @IsEdit = "#=Ord_ID#" }, getHtmlAttributesForActionLink("EditConsultation")) + "#} else if ( EventConsultStatusID == "
+ (int)MDA.AppConstants.ConstantValues.ConsultationStatus.WRITTEN + ") {# <a href= " + Url.Action("ReviewConsultation", "Customer", new { id = "#=Ord_ID#" }) + " > view consult <p> See Doctor Notes and place Order if Prescription Written </p> </a> #} else if (EventConsultStatusID == "
+ (int)MDA.AppConstants.ConstantValues.ConsultationStatus.PENDING + ") {# <a href=" + Url.Action("ReviewConsultation", "Customer", new { id = "#Ord_ID#" })
+ "> view consult <p> See Doctor Notes and Respond </p> </a> #} else if (Eligible_ReFill && (OS_ID == 35 || OS_ID == 41)){ # <p> Eligible for Re-fill </p> <span > Please click on View Consult Link to see Refill link </span> #} else if (Eligible_ReOrder && (OS_ID == 35 || OS_ID == 41) && EventTypeID == 1) {# <p> Eligible for Re-Order </p> <span > Please click on View Consult Link to see ReOrder link </span> #} else if (EventType == 'eConsult' || EventType == 'TeleConsult') {# <a href="
+ Url.Action("ReviewConsultation", "Customer", new { id = "#=Ord_ID#" }) + "> view consult </a> #} else {# <a href=" + Url.Action("OrderDetails", "Customer", new { id = "#=Ord_ID#" })
+ "> view consult </a> # } if (OS_ID ==" + (int)MDA.AppConstants.OrderStatus.AllOrderStatus.OrderShipped + " || OS_ID == " + (int)MDA.AppConstants.OrderStatus.AllOrderStatus.PickedFromLocalPharmacy + ") {# <a href='javascript:void(0);' onclick=javascript:CenterWindow(900,800,50,"
+ Url.Action("ViewReceipt", "Customer", new { id = "#=Ord_ID#" }) + ">);> View/Print Receipt </a> #} if (OS_ID != " + (int)MDA.AppConstants.OrderStatus.AllOrderStatus.OrderCanceled + ") {# <br /> <a href="
+ Url.Action("AttachReporToConsult", "Customer", new { OrderId = "#=Ord_ID#" }) + "> Attach Report </a> #} #").Title("Sample1").Width("25%");
})
.Resizable(resizing => resizing.Columns(true))
.Pageable(Page => Page.Refresh(true).PageSizes(true).PreviousNext(true))
.Filterable()
.Sortable()
.Scrollable()
.Groupable()
.Reorderable(reorder => reorder.Columns(true))
.DataSource(dataSource => dataSource.Ajax()
.Read(read => read.Action("_DemoDashBoard", "Customer", new { patientid = Model.CustomerID, startdate= Model.SearchStartDate, enddate=Model.SearchEndDate }))
.ServerOperation(false)
)
)
我认为您不需要 ajax 电话。试试这个,dataSource.read()
应该使用更新后的参数调用您的操作:
$("#showDate").click(function(){
var pid = $("#PatientID").val();
var dtStartDate = $("#startDate").val();
var dtEndDate = $("#endDate").val();
if(dtStartDate > dtEndDate) {
$("#spnshowDate").html("<html>From date should not be greater than To date</html>");
}
var grid = $("#gridOrders").data("kendoGrid");
grid.dataSource.read({ patientid: pid, startdate: dtStartDate, enddate: dtEndDate })
});