0

I am new in Kendo UI, I have one kendo DatePicker and one Kendo GridView. After selecting a date from DatePicker according the data should bind to the Kendo GridView. I use jquery with Ajax and my jquery function is

Click event

List<MDA.AppEntities.Orders.OrderList> objConsults = new List<MDA.AppEntities.Orders.OrderList>(); 
objConsults = DataFacade.Operations.GetCustomerOrderDetailsByCustomerID(Patientid,startDate,en‌​dDate ); 
return new PrimeJsonResult { MaxJsonLength = int.MaxValue, JsonRequestBehavior = JsonRequestBehavior.AllowGet, Data = new GridModel<MDA.AppEntities.Orders.OrderList> { Data = objConsults } };

It is going inside success: function(data), but not executing inside code and jump back to $.ajax(), and I don't understand why.

@(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)
    )
)
9
  • Please post your grid code.
    – Nic
    May 5, 2015 at 7:40
  • @Vash Action Result Method 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 } }; May 5, 2015 at 8:08
  • Please add new information to the question next time. :)
    – Nic
    May 5, 2015 at 22:17
  • You have a grid in your view named GridOrders, please add the source code for that grid to your question. That makes it easier to debug your issue.
    – Nic
    May 5, 2015 at 22:19
  • @Vash I added GridOrder View Code May 6, 2015 at 6:17

1 Answer 1

2

I don't think you need the ajax call. Try this, dataSource.read() should call your action with the updated parameters:

$("#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 })
});
3
  • what is the defect in My jquery function May 6, 2015 at 6:54
  • Ok I'll try and let you know May 6, 2015 at 7:05
  • I got my answer I used lots of JS files related to telerik and it conflict each other now I resolved it. May 6, 2015 at 7:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.