locked
Need help "search during infinite loading of data" RRS feed

  • Question

  • User-490550226 posted

    I need help,

    Here the problem is that I want to make an API for the app, during scroll I can search the data. In the below code, I am able to do Infinite scroll but not sure how to give search functionality.  For example, I have a scroll 3 pages (1 page have 10 records) and during that time I want to search string like "David" so it will give search string within 30 records 

    public dynamic GetAllUsersList(int Count, int UserId)
    {
    using (LystenEntities db = new LystenEntities())
    {
    OnlineUserViewModel uv = new OnlineUserViewModel();
    uv.TotalCount = db.User_Master.Where(x => x.IsActive == true).Where(x => x.RoleId != 1 && x.Id != UserId).ToList().Count();
    int skip = 10 * Count;
    string baseURL = HttpContext.Current.Request.Url.Authority;
    baseURL += (WebConfigurationManager.AppSettings["userimagepath"]).Replace("~", "");
    uv.userdetail =
    db.User_Master.Where(x => x.RoleId != 1 && x.Id != UserId && x.IsActive == true).Select(x => new userdetail()
    {
    Id = x.Id,
    Email = x.Email,
    Displayname = x.FullName == null ? "" : x.FullName,
    Image = (x.Image == null) ? "" : x.Image == "" ? "" : (baseURL + x.Image)
    }).OrderBy(x => x.Displayname).Skip(skip).Take(10).ToList();
    return uv;
    }


    " record at 3-page index</div>

    Monday, December 23, 2019 12:18 PM

All replies

  • User-719153870 posted

    Hi maddy1460,

    I am able to do Infinite scroll but not sure how to give search functionality.

    The requirement is not clear enough, do you have problem in how to select string LIKE "David" in Linq? If so, please check LINQ to SQL: How to write a 'Like' select?.

    Call this select method through Ajax in your Infinite scroll event.

    Best Regard,

    Yang Shen

    Tuesday, December 24, 2019 2:36 AM