示例#1
0
    protected void gvAdmin_Sorting(object sender, GridViewSortEventArgs e)
    {
        //if (ddlpageSize.SelectedValue != "")
        //{
        //    pageSize = Convert.ToInt32(ddlpageSize.SelectedValue);
        //}
        //if (ddlpage.SelectedValue != "")
        //{
        //    pageNo = Convert.ToInt32(ddlpage.SelectedValue);
        //}
        if (e.SortExpression.ToString() != string.Empty)
        {
            if (SortDirection.ToLower() == "asc")
            {
                SortDirection = "desc";
            }
            else
            {
                SortDirection = "asc";
            }

            SortExpression = e.SortExpression + " " + SortDirection;
            BindContents();
        }
    }
示例#2
0
        public void HeaderClick(object sender, EventArgs e)
        {
            RepeaterHeaderLink lb = (RepeaterHeaderLink)sender;

            if (SortColumn == lb.DataCol)
            {
                if (SortDirection.ToLower() != "asc")
                {
                    SortDirection = "asc";
                }
                else
                {
                    SortDirection = "desc";
                }
            }
            else
            {
                SortDirection = "asc";
            }

            SortColumn = lb.DataCol;

            if (this.SortColumn != "")
            {
                string sortStr = this.SortColumn + " " + this.SortDirection.ToUpper();
                DataSource.DefaultView.Sort = sortStr;
            }

            DataBind();
        }
示例#3
0
    protected void gvAdmin_Sorting(object sender, GridViewSortEventArgs e)
    {
        if (e.SortExpression.ToString() != string.Empty)
        {
            if (SortDirection.ToLower() == "asc")
            {
                SortDirection = "desc";
            }
            else
            {
                SortDirection = "asc";
            }

            SortExpression = e.SortExpression + " " + SortDirection;
            GetOrderDetails();
        }
    }
示例#4
0
    protected void GVOrder_Sorting(object sender, GridViewSortEventArgs e)
    {
        if (e.SortExpression.ToString() != string.Empty)
        {
            if (SortDirection.ToLower() == "asc")
            {
                SortDirection = "desc";
            }
            else
            {
                SortDirection = "asc";
            }

            SortExpression = e.SortExpression + " " + SortDirection;
            BindProduct();
        }
    }
示例#5
0
        protected override void Render(HtmlTextWriter output)
        {
            var rc = new RoleController();

            var whereCls = new List <Func <RoleInfo, bool> >();

            whereCls.Add(grp => grp.SecurityMode != SecurityMode.SecurityRole);
            if (RoleGroupId >= -1)
            {
                whereCls.Add(grp => grp.RoleGroupID == RoleGroupId);
            }
            whereCls.Add(grp => grp.Status == RoleStatus.Approved);

            if (DisplayCurrentUserGroups)
            {
                whereCls.Add(grp => currentUser.IsInRole(grp.RoleName));
            }
            else
            {
                whereCls.Add(grp => grp.IsPublic || currentUser.IsInRole(grp.RoleName));
            }

            if (!string.IsNullOrEmpty(SearchFilter))
            {
                whereCls.Add(grp => grp.RoleName.ToLower().Contains(SearchFilter.ToLower()) || grp.Description.ToLower().Contains(SearchFilter.ToLower()));
            }

            var roles = TestableRoleController.Instance.GetRoles(PortalSettings.PortalId, grp => TestPredicateGroup(whereCls, grp));

            if (SortDirection.ToLower() == "asc")
            {
                roles = roles.OrderBy(info => GetOrderByProperty(info, SortField)).ToList();
            }
            else
            {
                roles = roles.OrderByDescending(info => GetOrderByProperty(info, SortField)).ToList();
            }

            decimal pages = (decimal)roles.Count / (decimal)PageSize;


            output.Write(HeaderTemplate);


            ItemTemplate = ItemTemplate.Replace("{resx:posts}", Localization.GetString("posts", Constants.SharedResourcesPath));
            ItemTemplate = ItemTemplate.Replace("{resx:members}", Localization.GetString("members", Constants.SharedResourcesPath));
            ItemTemplate = ItemTemplate.Replace("{resx:photos}", Localization.GetString("photos", Constants.SharedResourcesPath));
            ItemTemplate = ItemTemplate.Replace("{resx:documents}", Localization.GetString("documents", Constants.SharedResourcesPath));

            ItemTemplate = ItemTemplate.Replace("{resx:Join}", Localization.GetString("Join", Constants.SharedResourcesPath));
            ItemTemplate = ItemTemplate.Replace("{resx:Pending}", Localization.GetString("Pending", Constants.SharedResourcesPath));
            ItemTemplate = ItemTemplate.Replace("{resx:LeaveGroup}", Localization.GetString("LeaveGroup", Constants.SharedResourcesPath));
            ItemTemplate = ItemTemplate.Replace("[GroupViewTabId]", GroupViewTabId.ToString());

            if (roles.Count == 0)
            {
                output.Write(String.Format("<div class=\"dnnFormMessage dnnFormInfo\"><span>{0}</span></div>", Localization.GetString("NoGroupsFound", Constants.SharedResourcesPath)));
            }


            if (!string.IsNullOrEmpty(HttpContext.Current.Request.QueryString["page"]))
            {
                CurrentIndex = Convert.ToInt32(HttpContext.Current.Request.QueryString["page"].ToString());
                CurrentIndex = CurrentIndex - 1;
            }

            int rowItem     = 0;
            int recordStart = (CurrentIndex * PageSize);

            if (CurrentIndex == 0)
            {
                recordStart = 0;
            }


            for (int x = recordStart; x < (recordStart + PageSize); x++)
            {
                if (x > roles.Count - 1)
                {
                    break;
                }

                var role = roles[x];

                string rowTemplate = ItemTemplate;

                if (rowItem == 0)
                {
                    output.Write(RowHeaderTemplate);
                }

                var groupParser = new GroupViewParser(PortalSettings, role, currentUser, rowTemplate, GroupViewTabId);
                output.Write(groupParser.ParseView());

                rowItem += 1;

                if (rowItem == ItemsPerRow)
                {
                    output.Write(RowFooterTemplate);
                    rowItem = 0;
                }
            }

            if (rowItem > 0)
            {
                output.Write(RowFooterTemplate);
            }


            output.Write(FooterTemplate);

            int TotalPages = Convert.ToInt32(System.Math.Ceiling(pages));


            if (TotalPages == 0)
            {
                TotalPages = 1;
            }

            string sUrlFormat = "<a href=\"{0}\" class=\"{1}\">{2}</a>";

            string[] currParams = new string[] { };

            StringBuilder sb = new StringBuilder();

            if (TotalPages > 1)
            {
                for (int x = 1; x <= TotalPages; x++)
                {
                    string[] @params = new string[] { };

                    if (currParams.Length > 0 & x > 1)
                    {
                        @params = Utilities.AddParams("page=" + x.ToString(), currParams);
                    }
                    else if (currParams.Length > 0 & x == 1)
                    {
                        @params = currParams;
                    }
                    else if (x > 1)
                    {
                        @params = new string[] { "page=" + x.ToString() };
                    }

                    string sUrl = Utilities.NavigateUrl(TabId, @params);

                    string cssClass = "pagerItem";

                    if (x - 1 == CurrentIndex)
                    {
                        cssClass = "pagerItemSelected";
                    }


                    sb.AppendFormat(sUrlFormat, sUrl, cssClass, x.ToString());
                }
            }

            output.Write("<div class=\"dnnClear groupPager\">");
            output.Write(sb.ToString());
            output.Write("</div>");
        }
示例#6
0
        public override void Process(TagHelperContext context, TagHelperOutput output)
        {
            IEnumerable model = DataModel.Model as IEnumerable;

            if (model == null)
            {
                return;
            }
            else
            {
                StringBuilder tableTag = new StringBuilder();

                //Getting properties for List Type
                Type listType   = Type.GetType(((System.Reflection.TypeInfo)(model.GetType()).GenericTypeArguments[0]).FullName);
                var  properties = listType.GetProperties();


                tableTag.Append("<thead><tr role='row'>");

                //Simple table, header not sortable
                if (!Sortable)
                {
                    foreach (var property in properties)
                    {
                        tableTag.Append("<th >");

                        //If the property has display name, get the display name
                        var isDisplayNameAttributeDefined = Attribute.IsDefined(property, typeof(DisplayNameAttribute));
                        if (isDisplayNameAttributeDefined)
                        {
                            DisplayNameAttribute dna = (DisplayNameAttribute)Attribute.GetCustomAttribute(property, typeof(DisplayNameAttribute));
                            tableTag.Append(dna.DisplayName);
                        }
                        else
                        {
                            tableTag.Append(property.Name.ToString());
                        }

                        tableTag.Append("</th>");
                    }
                }
                else   // for sortable table
                {
                    string linkPretextTag = "<a href = '/" + Controller + "/" + Action;
                    QueryString = QueryString ?? "";

                    foreach (var property in properties)
                    {
                        string columnName = property.Name.ToString();
                        var    isDisplayNameAttributeDefined = Attribute.IsDefined(property, typeof(DisplayNameAttribute));

                        if (isDisplayNameAttributeDefined)
                        {
                            DisplayNameAttribute dna = (DisplayNameAttribute)Attribute.GetCustomAttribute(property, typeof(DisplayNameAttribute));
                            columnName = dna.DisplayName;
                        }

                        tableTag.Append("<th aria-controls='");
                        tableTag.Append(ID);


                        if (property.Name.ToString().ToLower() == SortBy.ToLower())
                        {
                            //if sorted descending
                            if (SortDirection.ToLower() == "desc")
                            {
                                tableTag.Append("' class='sorting_desc' aria-sort='descending' aria-label='");
                                tableTag.Append(columnName);
                                tableTag.Append(": activate to sort column ascending' >");

                                tableTag.Append(linkPretextTag);
                                tableTag.Append("?sortorder=");
                                tableTag.Append(property.Name.ToString());
                                tableTag.Append(QueryString);
                                tableTag.Append("'>");
                                // sb.Append("&sortDirection=asc'>");
                            }
                            else
                            {
                                tableTag.Append("' class='sorting_asc' aria-sort='ascending' aria-label='");
                                tableTag.Append(columnName);
                                tableTag.Append(": activate to sort column descending' >");

                                tableTag.Append(linkPretextTag);
                                tableTag.Append("?sortorder=");
                                tableTag.Append(property.Name.ToString());
                                tableTag.Append(QueryString);
                                tableTag.Append("&sortDirection=desc'>");
                            }
                        }
                        else
                        {
                            tableTag.Append("' class='sorting' aria-label='");
                            tableTag.Append(columnName);
                            tableTag.Append(": activate to sort column ascending' >");

                            tableTag.Append(linkPretextTag);
                            tableTag.Append("?sortorder=");
                            tableTag.Append(property.Name.ToString());
                            tableTag.Append(QueryString);
                            tableTag.Append("'>");
                            // sb.Append("&sortDirection=asc'>");
                        }

                        tableTag.Append(columnName);
                        tableTag.Append("</a></th>");
                    }
                }


                tableTag.Append("</tr></thead>");
                //Generate data
                foreach (var m in model)
                {
                    PropertyInfo[] dataProperties = m.GetType().GetProperties();
                    tableTag.Append("<tr>");
                    for (int i = 0; i < dataProperties.Length; i++)
                    {
                        tableTag.Append("<td>" + m.GetType().GetProperty(dataProperties[i].Name).GetValue(m, null) + "</td>");
                    }
                    tableTag.Append("</tr>");
                }
                // tableTag.Append("<colgroup> <col span = '2' style = 'background-color:red' > <col style = 'background-color:yellow' ></colgroup>");
                output.Content.SetHtmlContent(tableTag.ToString());
            }
        }