This is a migrated thread and some comments may be shown as answers.

Kendo UI Grid Filter Binding Issues..

0 Answers 109 Views
Filter
This is a migrated thread and some comments may be shown as answers.
Sairam
Top achievements
Rank 1
Sairam asked on 09 Jun 2015, 11:52 AM
Model:-
public class PurchaseOrder
{
 
public string PlanedDate { get; set; }
public DateTime? PlanedDateTime { get; set; }
public string PlanedDateString { get; set; }
 
public string CompletionDate { get; set; }
 
        [Display(Name = "Completion Date")]
        public DateTime? CompletionDateTime { get; set; }
        public string CompletionDateString { get; set; }
 
 
 
}
 
 
 
Controller:-
private void ModifyFilters(IEnumerable<IFilterDescriptor> filters)
        {
            if (filters.Any())
            {
                foreach (var filter in filters)
                {
                    var descriptor = filter as FilterDescriptor;
 
                    if (descriptor != null && (descriptor.Member == "PlanedDateTime" || descriptor.Member == "ModifiedDateTime" || descriptor.Member == "CompletionDateTime" ||
                    descriptor.Member == "CharterDateTime" || descriptor.Member == "UpLiftDateTime" || descriptor.Member == "PurchaseOrderDateTime" || descriptor.Member == "InvoiceSubmittedDateTime"))
                    {
                         descriptor.Value = Convert.ToDateTime(descriptor.Value.ToString().Trim()).ToShortDateString();
                        //Not Equal Op  We send Only Date
                    }
  if (descriptor != null && descriptor.Member == "PlanedDateTime")
                    {
                        descriptor.Member = "PlanedDate";
                        
                    else if (filter is CompositeFilterDescriptor)
                    {
                        ModifyFilters(((CompositeFilterDescriptor)filter).FilterDescriptors);
                    }
                }
            }
        }

 

 

Controller:-
  public ActionResult PurchaseCellarOrder_Read([DataSourceRequest] DataSourceRequest request, FormCollection formcol)
        {
         XrmServiceContext xrm = new XrmServiceContext(CrmService.Service);
            var totalRecordCount = 0;
 
            Guid ParentCustomerId = xrm.ContactSet.SingleOrDefault(i => i.Id == new Guid(HttpContext.User.Identity.Name)).ParentCustomerId != null ? xrm.ContactSet.SingleOrDefault(i => i.Id == new Guid(HttpContext.User.Identity.Name)).ParentCustomerId.Id : Guid.Empty;
          List<PurchaseOrderModel> purchaseOrderList = new List<PurchaseOrderModel>();
            if (ParentCustomerId != Guid.Empty)
            {
                ModifyFilters(request.Filters);
                   po.PlanedDate = entity.Attributes.Contains("tcrmb_planneddate") ? (TimeZoneInfo.ConvertTimeFromUtc(Convert.ToDateTime(entity.Attributes["tcrmb_planneddate"].ToString()), timezone)).ToShortDateString().Trim() : "--";
                    po.PlanedDateTime = entity.Attributes.Contains("tcrmb_planneddate") ? (TimeZoneInfo.ConvertTimeFromUtc(Convert.ToDateTime(entity.Attributes["tcrmb_planneddate"].ToString()), timezone)).Date : (DateTime?)null;
                    po.PlanedDateString = entity.Attributes.Contains("tcrmb_planneddate") ? entity.FormattedValues["tcrmb_planneddate"] : "--";
   purchaseOrderList.Add(po);
             }
      var page = request.Page;
         
       request.Page = 1;
 
            var result = purchaseOrderList.ToDataSourceResult(request);
            if (totalRecordCount <= request.PageSize)
            {
                result.Total = purchaseOrderList.Count;
            }
            else
            {
                result.Total = totalRecordCount;
            }
 
            return Json(result);
}
View:-
 
 
@model SupplierPortal.Models.PurchaseOrderModel
@using Kendo.Mvc.UI
 
@(Html.Kendo().Grid<SupplierPortal.Models.PurchaseOrderModel>().Name("PurchaseCellarOrders")
                        .DataSource(ds => ds.Ajax()
                            .Read(r => r.Action("PurchaseCellarOrder_Read", "PurchaseOrder"))
                        .Model(m => m.Id(p => p.PurchaseOrderId))
                        .ServerOperation(true)
                         .Sort(sort => sort.Add(po=>po.ModifiedDateTime).Descending())        
                         .PageSize(50).Events(e => e.RequestEnd("requestEnd"))
                        )
                        .Columns(cols =>
                        {
                            cols.Bound(con => con.PurchaseOrderId).Title("<input type='checkbox' id='checkAll'/>").Filterable(false).Sortable(false)
                                .ClientTemplate("<input type='checkbox'  #=PurchaseOrderId ? checked='':'' # class='check-box' onchange='SetCheckBOX(this)'/>");
 
                            cols.Bound(con => con.PHCNumber).Title("PHC");
                            cols.Bound(con => con.PubName);
                            cols.Bound(con => con.PostCode);
                            cols.Bound(con => con.CaseNumber).Visible(false);
                            cols.Bound(con => con.PONumber).Title("Purchase Order Number");
                            cols.Bound(con => con.CharterDate).Format("{0:dd/MM/yyyy}").Visible(false);
                            cols.Bound(con => con.CharterDateTime).ClientTemplate("#=CharterDateString #");
                            cols.Bound(con => con.PlanedDate).Format("{0:dd/MM/yyyy}").Visible(false);
                            cols.Bound(con => con.PlanedDateTime).ClientTemplate("#=PlanedDateString #").Title("Planned Date");
                            cols.Bound(con => con.CompletionDate).Format("{0:dd/MM/yyyy}").Visible(false);
                            cols.Bound(con => con.CompletionDateTime).Title("Work Done Date").ClientTemplate("#=CompletionDateString #");
                            cols.Bound(con => con.Status).Filterable(false).Sortable(false).Visible(false);
                            cols.Bound(con => con.StatusReason).Sortable(false).Title("Status Reason");
                            cols.Bound(con => con.Classification).Width(120);
                            cols.Bound(con => con.ModifiedDate).Format("{0:dd/MM/yyyy}").Visible(false);
                            cols.Bound(con => con.ModifiedDateTime).ClientTemplate("#=ModifiedDateString #");
                            cols.Bound(con => con.InvoiceSubmittedDate).Format("{0:dd/MM/yyyy}").Visible(false);
                            cols.Bound(con => con.InvoiceSubmittedDateTime).Title("Invoice Submitted").ClientTemplate("#=InvoiceSubmittedDateString #");
                            cols.Bound(con => con.OnHold);
                            cols.Bound(con => con.OnHoldBool).Visible(false);
 
                            //cols.Bound(con => con.PONumber);
 
 
                        })
                                                 .Selectable(selectable => selectable.Mode(GridSelectionMode.Multiple).Type(GridSelectionType.Row))
        //.Events(events => events.DataBound("onDataBound"))
                                                 .Pageable()
                                                 .Sortable()
                                                 .Filterable()
 
    )

 

 here I got Filter Binding issues...when Give 28/05/2014 in Planned Date 28/05/2015  "On or Before"  in Controller Side I got Full record But it Excute  the Following line

 var result = purchaseOrderList.ToDataSourceResult(request); 

Some Of the Records are missing ....I unable to find where the ..issues 

I attach Following image First one is webportal one...in this we missing 2  records of planned date 08/05/2015 and 07/05/2015 but it exist in Controller At the time of binding...It Show in second image .....help me here ...where is the  issues.

 

 

No answers yet. Maybe you can help?

Tags
Filter
Asked by
Sairam
Top achievements
Rank 1
Share this question
or