Grid Customize Datasource Request Filters

0 Answers 46 Views
Grid
DPA
Top achievements
Rank 1
DPA asked on 19 Jan 2024, 05:45 AM

Hi, I have this list of thousands of employees from our Database and will be displayed in a Grid via ViewModel. Im using Custom Binding with paging to fetch only specific number of records per page to reduce the loading time of the grid thats why the ServerOperation = true.

My problem is that, how can I customize or recreate the request filters? Since FullName and Address does not exists in the Employees table. I'm getting error whenever i use search.

 

public class Employee
    {
        public string EmployeeID { get; set; }

        public string LastName { get; set; }
        public string FirstName { get; set; }

        public string Street { get; set; }
        public string City { get; set; }
        public string Province { get; set; }

        public string TelephoneNo { get; set; }

        public string FullName
        {
            get
            {
                return String.Format("{0}, {1}", LastName, FirstName ?? "");
            }
        }

        public string Address
        {
            get
            {
                return String.Format("{0} {1} {2}", Street, City, Province);
            }
        }
    }

@(Html.Kendo().Grid<Employee>()
    .Name("gridEmployees")
    .ToolBar(toolbar =>
    {
        toolbar.Search();
    })
    .Columns(column =>
    {
        column.Bound(c => c.EmployeeID);
        column.Bound(c => c.FullName);
        column.Bound(c => c.Address);
        column.Bound(c => c.TelephoneNo);
    })
    .Filterable()
    .AutoBind(false)
    .DataSource(ds =>
    {
        ds.Ajax()
        .ServerOperation(true)
        .PageSize(10)
        .Model(m => m.Id(c => c.EmployeeID))
        .Read(r => r.Action("Read", "Employees"));
    })
)

        

No answers yet. Maybe you can help?

Tags
Grid
Asked by
DPA
Top achievements
Rank 1
Share this question
or