Ejemplo n.º 1
0
 public Pager(IPageableModel model, ViewContext context)
 {
     this.model = model;
     this.viewContext = context;
     this.urlBuilder = CreateDefaultUrl;
     this.booleanParameterNames = new List<string>();
 }
Ejemplo n.º 2
0
 public Pager(IPageableModel model, ViewContext context)
 {
     this.model                 = model;
     this.viewContext           = context;
     this.urlBuilder            = CreateDefaultUrl;
     this.booleanParameterNames = new List <string>();
 }
 public AjaxPager(IPageableModel model, ViewContext context,string containEl)
 {
     this.model = model;
     this.viewContext = context;
     this.urlBuilder = CreateDefaultUrl;
     this.booleanParameterNames = new List<string>();
     this._containDiv = containEl;
 }
Ejemplo n.º 4
0
        public static ViewOptions GetOptions(this IPageableModel model)
        {
            var options = new ViewOptions();

            options.Descending = model.Descending;
            options.StartKey.Add(model.StartKey);
            options.Skip          = model.Skip;
            options.Stale         = model.Stale;
            options.StartKeyDocId = model.StartKeyDocId;
            options.EndKeyDocId   = model.EndKeyDocId;
            options.Limit         = model.Limit.HasValue ? model.Limit : 10;
            return(options);
        }
Ejemplo n.º 5
0
        public static void UpdatePaging(this IPageableModel model, IViewOptions options, IViewResult result)
        {
            int count = result.Rows.Count();
            var limit = options.Limit.HasValue ? options.Limit.Value : 10;

            model.Limit = limit;
            int rowsMinusOffset = (result.TotalRows - result.OffSet);

            model.ShowPrev = result.OffSet != 0 && !(model.Descending && (rowsMinusOffset <= count));
            model.ShowNext = (result.TotalRows > options.Limit + result.OffSet) || options.Descending.GetValueOrDefault();
            string skipPrev = result.OffSet < limit ? "" : "&skip=1";
            string skipNext = rowsMinusOffset < limit ? "" : "&skip=1";
            JToken lastRow;
            JToken firstRow;

            if (options.Descending.HasValue && options.Descending.Value)
            {   //descending
                lastRow          = result.Rows.FirstOrDefault();
                firstRow         = result.Rows.LastOrDefault();
                model.StartIndex = (rowsMinusOffset - limit) < 1 ? 1 : (rowsMinusOffset - limit + 1);
            }
            else
            {   //ascending
                lastRow          = result.Rows.LastOrDefault();
                firstRow         = result.Rows.FirstOrDefault();
                model.StartIndex = result.OffSet + 1;
            }

            var startIndexPlusCount = model.StartIndex + count - 1;

            model.EndIndex = result.TotalRows == 0 ? 0 : startIndexPlusCount;
            if (count == 0)
            {
                model.EndIndex = model.StartIndex = 0;
            }

            model.TotalRows = result.TotalRows;
            string prevStartKey = firstRow != null ? "&startkey=" + HttpUtility.UrlEncode(firstRow.Value <string>("key")) + "&StartKeyDocId=" + firstRow.Value <string>("id") : "";
            string nextStartKey = lastRow != null ? "&startkey=" + HttpUtility.UrlEncode(lastRow.Value <string>("key")) + "&StartKeyDocId=" + lastRow.Value <string>("id") : "";

            model.NextUrlParameters = "?limit=" + model.Limit + nextStartKey + skipNext;
            model.PrevUrlParameters = "?limit=" + model.Limit + prevStartKey
                                      + skipPrev +
                                      "&descending=true";
        }
Ejemplo n.º 6
0
 public static Pager Pager(this IHtmlHelper helper, IPageableModel pagination)
 {
     return(new Pager(pagination, helper.ViewContext));
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Ctor
 /// </summary>
 /// <param name="model">Model</param>
 /// <param name="context">ViewContext</param>
 public Pager(IPageableModel model, ViewContext context)
 {
     this.model                 = model;
     this.viewContext           = context;
     this.booleanParameterNames = new List <string>();
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Prepare a common pager
 /// </summary>
 /// <param name="helper">HTML helper</param>
 /// <param name="model">Pager model</param>
 /// <returns>Pager</returns>
 /// <remarks>We have two pagers: The first one can have custom routes. The second one just adds query string parameter</remarks>
 public static Pager Pager(this IHtmlHelper helper, IPageableModel model)
 {
     return(new Pager(model, helper.ViewContext));
 }
Ejemplo n.º 9
0
        //protected int PageNumber { get; set; }

        /// <summary>
        /// Ctor
        /// </summary>
        /// <param name="model">Model</param>
        /// <param name="context">ViewContext</param>
        public Pager(IPageableModel model, string url)
        {
            this.model = model;
            this.uri   = new Uri(url);
            this.booleanParameterNames = new List <string>();
        }
Ejemplo n.º 10
0
 public Pager(IPageableModel model, ViewContext context)
 {
     _model      = model;
     ViewContext = context;
 }
Ejemplo n.º 11
0
 //jsut a copy of \Presentation\Nop.Web\Extensions\PagerHtmlExtension.cs
 public static Pager Pager(this HtmlHelper helper, IPageableModel pagination)
 {
     return new Pager(pagination, helper.ViewContext);
 }
Ejemplo n.º 12
0
 public static AlbionPager AlbionPager(this HtmlHelper helper, IPageableModel pagination)
 {
     return(new AlbionPager(pagination, helper.ViewContext));
 }
Ejemplo n.º 13
0
 public static Pager Pager(this IHtmlHelper helper, IPageableModel pagination, string path)
 {
     return(new Pager(pagination, path));
 }
 public static AjaxPager AjaxPager(this HtmlHelper helper, IPageableModel pagination,string containEl)
 {
     return new AjaxPager(pagination, helper.ViewContext,containEl);
 }