Skip to content

ANgularJS Grid diplay based on RoleID

Vibha Grover

Asked Jun 23, 2014, 5:59 PM EDT1 answer
Share
LinkedInX
Hi ,
 
 My Grid is displaying all the data from view created on DB using below code.
 
[Queryable]
Code
        public IQueryable<mydata> Get()
        {
            return mda.GetAll();
        }
 
 
C#
public interface IGenericRepository<T, TEntity> : IDisposable
    {
 IQueryable<T> GetAll(string[] includes = null);
}
 
 
C#
 public virtual IQueryable<T> GetAll(string[] includes = null)
        {
            if (includes != null && includes.Count() > 0)
            {
                var query = _context.Set<TEntity>().Include(includes.First());
                foreach (var include in includes.Skip(1))
                    query = query.Include(include);
                return query.Project().To<T>();
            }

            return _context.Set<TEntity>().Project().To<T>();
        }
 
 Now I just want to display all the records based on Role ID as the person who has logged in my site his role should be assigner and all assigned items to him would be displayed. In my view AssignerId is displayed. I am not aware  where to put where condition in this case.
 
I am using AngularJS, MVC5.0, Entity Framework. Please advice me asap.
 
Thanks & Regards,
Care Career 

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    Hi Vibha,

    You've not posted your Angular code, anyway if you're getting all records from backend you need to filter at your AngularJS controller. These tasks like filtering records are cup of cake if you use Functional programming capabilities or libraries, e.g., underscore.js [for more info you can read my blog on it http://www.c-sharpcorner.com/Blogs/15833/underscore-js-tutorial.aspx

    If I visualize it'll be in JS e.g.,
    var roleId= 10;
    var AllData=$scope.AllData;
    $scope.FilteredResults=_.where(AddData, {RoleID: roleId});

    Now you can show $scope.FilteredResults in your ng-Repeat

    Thnx
    @sumitjolly
    0