GridMvc not filtering all Fields

Refresh

April 2019

Views

119 time

1

I'm using GridMvc with asp.net mvc 4.5. All of the filters are working except a few strings. I can't see any difference between these strings and the strings that are working. What am I missing?

View @model Infotech.Coverpools.Portal.Tintaglia.Web.Models.AccountHistoryVM @using GridMvc.Html

<h2>Account History</h2>    
@Html.Grid(Model.Records).Columns(columns =>
{
    columns.Add(m => m.CustomerNo_).Titled("Account #").Filterable(false); 
    columns.Add(m => m.PostingDate).Format("{0:MM/dd/yyyy}").SetWidth(100).Titled("Order Date").Filterable(true); //filter
    columns.Add(m => m.DocumentType).Titled("Type").Filterable(true); //filters
    **columns.Add(m => m.DocumentNo_).Titled("Document #").Filterable(true); //doesn't filter**
    columns.Add(m => m.Description).Titled("Description").SetWidth(300).Filterable(true); //filters
    **columns.Add(m => m.ExternalDocumentNo_).Titled("Memo").SetWidth(300).Filterable(true); //doesn't filter**
    columns.Add(m => m.Amount).Format("{0:$#,###.00}").Titled("Original Amount").SetWidth(200).Filterable(true); //filters
    columns.Add(m => m.RemainingAmount).Format("{0:$#,###.00}").SetWidth(100).Titled("Remaining Amount").Filterable(true); //filters
    columns.Add(m => m.DueDate).Format("{0:MM/dd/yyyy}").Titled("Due Date").Filterable(true); 
}).WithPaging(20).Sortable(true) //filters
<script src="~/Scripts/gridmvc.js"></script>

Model

using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;

namespace Infotech.Coverpools.Portal.Tintaglia.CodeFirst.Models
{
    [Table("CustLedgerEntry")]
    public class CustLedgerEntry
    {
        [Key]
        [Column(Order = 0)]
        [DatabaseGenerated(DatabaseGeneratedOption.None)]
        public int EntryNo_ { get; set; }

        [StringLength(20)]
        public string CustomerNo_ { get; set; }

        public DateTime PostingDate { get; set; }

        [StringLength(20)]
        public string DocumentType { get; set; }


        [StringLength(20)]
        public string DocumentNo_ { get; set; }

        [StringLength(50)]
        public string Description { get; set; }

        [StringLength(35)]
        public string ExternalDocumentNo_ { get; set; }

        [DataType(DataType.Currency)]
        public decimal Amount { get; set; }

        [DataType(DataType.Currency)]
        public decimal RemainingAmount { get; set; }

        [DataType(DataType.Date)]
        public DateTime DueDate { get; set; }

        [DataType(DataType.DateTime)]
        public DateTime DatetoWebSales { get; set; }

        [StringLength(3)]
        public string Open { get; set; }
    }
}

Controller

public ActionResult AccountHistory()
{

    var dealerId = db.UserProfiles.Where(d => d.UserName.Equals(User.Identity.Name)).Select(d => d.CustomerId).FirstOrDefault();

    var vm = new AccountHistoryVM();
    vm.Records = db.CustLedgerEntries.ToList().Where(x => x.CustomerNo_.Equals(dealerId, StringComparison.OrdinalIgnoreCase));

    var datetoweb = db.CustLedgerEntries.FirstOrDefault(m => m.DatetoWebSales != null);
    vm.LastUpdatedDate = datetoweb.DatetoWebSales;
    return View(vm);
}

1 answers

0

Hi I have just removed underscore(_) from model and your grid it is working fine now.

Model

Grid

Grid

    <div class="container">
@Html.Grid(Model).Columns(columns =>
{
    columns.Add(m => m.CustomerNo_).Titled("Account #").Filterable(false);
    columns.Add(m => m.PostingDate).Format("{0:MM/dd/yyyy}").SetWidth(100).Titled("Order Date").Filterable(true); //filter
    columns.Add(m => m.DocumentType).Titled("Type").Filterable(true); //filters
    columns.Add(m => m.DocumentNo).Titled("Document").Filterable(true); //doesn't filter**
    columns.Add(m => m.Description).Titled("Description").SetWidth(300).Filterable(true); //filters
    columns.Add(m => m.ExternalDocumentNo).Titled("Memo").SetWidth(300).Filterable(true); //doesn't filter**
    columns.Add(m => m.Amount).Format("{0:$#,###.00}").Titled("Original Amount").SetWidth(200).Filterable(true); //filters
    columns.Add(m => m.RemainingAmount).Format("{0:$#,###.00}").SetWidth(100).Titled("Remaining Amount").Filterable(true); //filters
    columns.Add(m => m.DueDate).Format("{0:MM/dd/yyyy}").Titled("Due Date").Filterable(true);
}).WithPaging(20).Sortable(true) 
    </div>

Output

enter image description here