/// <summary> /// 根据新的排序部分预取 URL,同时页序号被重置为初始值。如果指定的字段为当前所使用的排序字段,则反转之 /// </summary> /// <param name="fieldName"></param> /// <param name="descendAsDefault"></param> /// <returns></returns> public string PrefetchNewToggleSortUrl(string fieldName, bool descendAsDefault) { fieldName = RetrieveFieldName(fieldName); ISortPart sortPart = null; if (this.m_sorts.Count == 0) { sortPart = new SortPart(fieldName, descendAsDefault); } else if (this.OneSortOnly) { ISortPart existed = this.m_sorts[0] as ISortPart; if (string.Compare(existed.FieldName, fieldName, true) == 0) { sortPart = new SortPart(fieldName, !existed.Descend); } else { sortPart = new SortPart(fieldName, descendAsDefault); } } else { ISortPart existed = null; IList<ISortPart> sorts = new List<ISortPart>(); foreach (ISortPart sort in this.m_sorts) { if (string.Compare(sort.FieldName, fieldName, true) != 0) { sorts.Add(sort); } else { existed = sort; } } if (existed != null) { sortPart = new SortPart(fieldName, !existed.Descend); } else { sortPart = new SortPart(fieldName, descendAsDefault); } sorts.Insert(0, sortPart); } return BuildUrl(this.m_filters, new ISortPart[] { sortPart }, FIRST_PAGE_INDEX); }
/// <summary> /// 根据新的排序部分预取 URL,同时页序号被重置为初始值 /// </summary> /// <param name="fieldName"></param> /// <param name="descend"></param> /// <returns></returns> public string PrefetchNewSortUrl(string fieldName, bool descend) { fieldName = RetrieveFieldName(fieldName); ISortPart sortPart = new SortPart(fieldName, descend); if (this.OneSortOnly || this.m_sorts.Count == 0 || ((this.m_sorts.Count == 1) && (string.Compare((this.m_sorts[0] as ISortPart).FieldName, fieldName, true) == 0))) { return BuildUrl(this.m_filters, new ISortPart[] { sortPart }, FIRST_PAGE_INDEX); } else { IList<ISortPart> sorts = new List<ISortPart>(); sorts.Add(sortPart); foreach (ISortPart sort in this.m_sorts) { if (string.Compare(sort.FieldName, fieldName, true) != 0) { sorts.Add(sort); } } return BuildUrl(this.m_filters, sorts, FIRST_PAGE_INDEX); } }