Example #1
0
        public TableViewModel(SortingPagingViewModel sortingPaging, string defaultSort, bool sortAscending = true)
            : this()
        {
            if (sortingPaging != null)
            {
                // Copy Sorting/Paging Settings from POST
                this.SortingPaging = sortingPaging;
            }

            // Initialize Defaults for Sorting/Paging
            if (sortingPaging.SortProperty == null)
            {
                this.SortingPaging.SortAscending = this.SortingPaging.SortProperty == null ? sortAscending : this.SortingPaging.SortAscending;
                this.SortingPaging.SortProperty  = this.SortingPaging.SortProperty ?? defaultSort;
            }

            if (sortingPaging.Page > sortingPaging.MaxPage)
            {
                sortingPaging.Page = sortingPaging.MaxPage;
            }
            if (sortingPaging.Page < 1)
            {
                sortingPaging.Page = 1;
            }
        }
Example #2
0
        public TableViewModel()
        {
            RenderHeader  = true;
            Filters       = new List <FilterViewModel>();
            Columns       = new List <ColumnViewModel <T> >();
            SortingPaging = new SortingPagingViewModel();

            var subject = typeof(T);

            foreach (var prop in subject.GetProperties())
            {
                Columns.Add(new ColumnViewModel <T>(prop));
            }
            IsPaginationEnabled = true;
            IsSearchingEnabled  = false;
        }