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

fetch page size recored from database to display in radgrid ?

1 Answer 39 Views
Grid
This is a migrated thread and some comments may be shown as answers.
hamid
Top achievements
Rank 1
hamid asked on 21 Jan 2016, 12:42 PM

Hi

I wana to fetch page size  of radgrid record from data base , but in your online demo code  , you used   (select * from xxx) !...

in this link

http://demos.telerik.com/aspnet-ajax/grid/examples/performance/linq/defaultcs.aspx

you talk about performance ! but if my table has a lot of recored , why i should fetch all of them ???

In  asp.net 4.5  for   "  asp:GridView  " control i can use this code :

 

public IEnumerable<SearchProvince> GetProvinces(int startRowIndex, int maximumRows, out int totalRowCount,
             [System.Web.ModelBinding.Control("pID")]int? provinceId,
             [System.Web.ModelBinding.Control("pName")] string provinceName)
        {
            using (var db = new XXXEntities())
            {
                IQueryable<Province> list =
                    (from p in db.Provinces
                     select new SearchProvince { ProvinceID = p.ProvinceID, ProvinceName = p.ProvinceName }).OrderBy(
                            p => p.ProvinceName);

                if (provinceId > 0)
                {
                    startRowIndex = 0;
                    list = list.Where(p => p.ProvinceID == provinceId);
                }
                if (!string.IsNullOrWhiteSpace(provinceName))
                {
                    startRowIndex = 0;
                    list = list.Where(p => p.ProvinceName.StartsWith(provinceName));
                }
                totalRowCount = list.Count();
                return list.Skip(startRowIndex).Take(maximumRows).ToList();
            }
        }

 

How can i implement this code for  RadGrid ?

 

thanks

1 Answer, 1 is accepted

Sort by
0
Viktor Tachev
Telerik team
answered on 25 Jan 2016, 02:08 PM
Hello Hamid,

Similar behavior can be implemented for RadGrid. If you would like to retrieve only the relevant items from the data source you can implement custom paging.

Check out the following example that illustrates the approach:



Regards,
Viktor Tachev
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Grid
Asked by
hamid
Top achievements
Rank 1
Answers by
Viktor Tachev
Telerik team
Share this question
or