Example #1
0
        private void RenderRefereceItem(HtmlTextWriter writer, ListControlItem item, BaseListDataBoundRenderEventArgs args)
        {
            if (!item.Enabled)
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Disabled, "disabled");
            }
            var url = string.Format("/MainPage.aspx/data/{0}Edit/read?ref{0}={1}", ReferenceTableName, item.ReferenceValue);

            writer.AddAttribute(HtmlTextWriterAttribute.Href, url);
            writer.AddAttribute(HtmlTextWriterAttribute.Target, "_blank");
            writer.RenderBeginTag(HtmlTextWriterTag.A);
            writer.Write(HttpUtility.HtmlEncode(item.Text));
            writer.RenderEndTag();
        }
Example #2
0
        internal string Render(ListControlItem item)
        {
            _dontRenderTd = true;
            var sb = new StringBuilder();

            using (var textWriter = new StringWriter(sb))
                using (var writer = new HtmlTextWriter(textWriter))
                {
                    var args = new BaseListDataBoundRenderEventArgs {
                        RowsCount = 1, Width = "100%"
                    };
                    RenderItem(writer, item, args);
                }
            return(sb.ToString());
        }
        protected override void RenderContents(HtmlTextWriter writer)
        {
            RenderBeginRows(writer);
            //если контрол только для чтения, то отображаем выбранные записи
            var items = ReadOnly || ShowOnlySelected
                            ? Items.Where(r => r.AnySelected()).ToList()
                            : Items;

            var rowsCount = (int)Math.Ceiling(items.Count / (decimal)Columns);

            if (RenderOnlyText)
            {
                rowsCount = 1;
            }

            var width = (100 / Columns) + "%";
            var args  = new BaseListDataBoundRenderEventArgs {
                RowsCount = rowsCount, Width = width
            };

            RenderItems(writer, items, args);
            RenderEndRows(writer);
        }
        protected override void RenderItem(HtmlTextWriter writer, ListControlItem item, BaseListDataBoundRenderEventArgs args)
        {
            if (RenderOnlyText)
            {
                writer.Write(item.Text);
                return;
            }

            if (!string.IsNullOrEmpty(item.ToolTip))
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Title, item.ToolTip);
            }
            writer.AddStyleAttribute(HtmlTextWriterStyle.Width, args.Width);
            writer.RenderBeginTag(HtmlTextWriterTag.Td);
            if (!item.Selected)
            {
                writer.WriteBeginTag("del");
            }

            #region checkbox

            if (!ReadOnly && item.Enabled && item.Selected)
            {
                var link = new BaseHyperLink
                {
                    Url     = "javascript:void(0);",
                    OnClick = string.Format("MultipleLookupSelect_DeleteItem(this, '{0}', '{1}', '{2}'); return false;", ClientID, item.SelectedKey, item.Value),
                    ImgUrl  = Themes.IconUrlDelete,
                };
                link.Render(writer, null);
                writer.Write(" ");
            }

            #endregion

            #region Label

            writer.RenderBeginTag(HtmlTextWriterTag.Span);

            if (!string.IsNullOrEmpty(item.Text))
            {
                var text = HttpUtility.HtmlEncode(item.Text);
                if (!string.IsNullOrEmpty(text))
                {
                    writer.Write(text.Replace("\r\n", "<br />"));
                }
            }

            writer.RenderEndTag();

            #endregion

            if (!item.Selected)
            {
                writer.WriteEndTag("del");
            }

            writer.RenderEndTag();
        }
        protected virtual void RenderGroupItem(HtmlTextWriter writer, ListControlItem item, BaseListDataBoundRenderEventArgs args)
        {
            if (RenderOnlyText)
            {
                RenderItems(writer, item, args);
            }
            else
            {
                var clientID = item.Value;
                writer.RenderBeginTag(HtmlTextWriterTag.Tr);       //tr
                writer.RenderBeginTag(HtmlTextWriterTag.Td);       //Td
                writer.RenderBeginTag(HtmlTextWriterTag.Div);      //outer DIV
                writer.RenderBeginTag(HtmlTextWriterTag.Fieldset); //Fieldset

                #region Legend

                writer.RenderBeginTag(HtmlTextWriterTag.Legend);

                if (item.Selectable && item.ChildrenCount() > 1)
                {
                    var checkBox = new BaseCheckBox
                    {
                        Checked = item.AllSelected(),
                        OnClick = "CheckInInnerGroup(this);",
                    };
                    checkBox.Render(writer, ExtenderAjaxControl);
                }

                writer.AddStyleAttribute(HtmlTextWriterStyle.Cursor, "pointer");
                writer.AddAttribute(HtmlTextWriterAttribute.Id, clientID + "_Legend");
                writer.AddAttribute(HtmlTextWriterAttribute.Title, Resources.PressToOpenCloseGroup);
                writer.AddAttribute("ondblclick", "ClickInnerGroup(this);");
                writer.AddAttribute("clickOnDblClickInParent", "on");
                writer.RenderBeginTag(HtmlTextWriterTag.Span);
                writer.Write(item.Text);
                writer.RenderEndTag(); //Span

                writer.RenderEndTag(); //Legend

                #endregion

                writer.AddAttribute(HtmlTextWriterAttribute.Id, clientID);
                writer.RenderBeginTag(HtmlTextWriterTag.Div); //inner DIV

                #region Table

                writer.AddAttribute(HtmlTextWriterAttribute.Border, "0");
                writer.AddStyleAttribute(HtmlTextWriterStyle.Width, "100%");
                writer.RenderBeginTag(HtmlTextWriterTag.Table);

                RenderItems(writer, item, args);

                writer.RenderEndTag(); //table

                #endregion

                writer.RenderEndTag(); //inner DIV

                writer.RenderEndTag(); //Fieldset
                writer.RenderEndTag(); //outer DIV
                writer.RenderEndTag(); //td
                writer.RenderEndTag(); //tr
            }
        }
        protected virtual void RenderItems(HtmlTextWriter writer, List <ListControlItem> items, BaseListDataBoundRenderEventArgs args)
        {
            if (items.Any(r => r.Children != null && r.Children.Count > 0))
            {
                foreach (var child in items)
                {
                    if (child.IsGroup)
                    {
                        args.RowsCount = (int)Math.Ceiling(child.ChildrenCount() / (decimal)Columns);
                        if (child.HideGroup)
                        {
                            RenderItems(writer, child, args);
                        }
                        else
                        {
                            RenderGroupItem(writer, child, args);
                        }
                    }
                    else
                    {
                        if (!RenderOnlyText)
                        {
                            writer.RenderBeginTag(HtmlTextWriterTag.Tr);
                        }

                        RenderItem(writer, child, args);

                        if (RenderOnlyText)
                        {
                            writer.Write("\r\n");
                        }
                        else
                        {
                            writer.RenderEndTag();
                        }
                    }
                }
            }
            else if (Columns == 1)
            {
                foreach (var item in items)
                {
                    writer.RenderBeginTag(HtmlTextWriterTag.Tr);
                    RenderItem(writer, item, args);
                    writer.RenderEndTag();
                }
            }
            else
            {
                // обход по строкам, затем выбиараем запись в слудующую колнку, т.е. шаг по записям по кол-ву строк. Пример обхода:
                // 1 4 7
                // 2 5 8
                // 3 6
                for (var rowIndex = 0; rowIndex < args.RowsCount; rowIndex++)
                {
                    for (var index = rowIndex; index < items.Count; index += args.RowsCount)
                    {
                        var needBeginTr = index == rowIndex;
                        var needEndTr   = index + args.RowsCount >= items.Count;

                        if (needBeginTr)
                        {
                            writer.RenderBeginTag(HtmlTextWriterTag.Tr);
                        }

                        RenderItem(writer, items[index], args);

                        if (needEndTr)
                        {
                            writer.RenderEndTag();
                        }
                    }
                }
            }
        }
        protected virtual void RenderItems(HtmlTextWriter writer, ListControlItem item, BaseListDataBoundRenderEventArgs args)
        {
            var children = ReadOnly || ShowOnlySelected
                               ? item.Children.Where(r => r.AnySelected()).ToList()
                               : item.Children;

            RenderItems(writer, children, args);
        }
 protected abstract void RenderItem(HtmlTextWriter writer, ListControlItem item,
                                    BaseListDataBoundRenderEventArgs args);
Example #9
0
        protected override void RenderItem(HtmlTextWriter writer, ListControlItem item, BaseListDataBoundRenderEventArgs args)
        {
            if (!_dontRenderTd)
            {
                if (!string.IsNullOrEmpty(item.ToolTip))
                {
                    writer.AddAttribute(HtmlTextWriterAttribute.Title, item.ToolTip);
                }
                writer.AddStyleAttribute(HtmlTextWriterStyle.Width, args.Width);
                writer.RenderBeginTag(HtmlTextWriterTag.Td);
            }

            #region Download file

            var linkBuilder = string.IsNullOrEmpty(item.SelectedKey) ? DefaultFileLinkBuilder : FileLinkBuilder;
            var fileLink    = new FileLinkWithPreview
            {
                FileName        = item.Text,
                FileLinkBuilder = linkBuilder,
            };
            linkBuilder.FileName = item.Text;
            linkBuilder.KeyValue = item.SelectedKey ?? item.Value;
            fileLink.FileManager = linkBuilder.FileManager;
            fileLink.FieldName   = linkBuilder.FieldName;
            fileLink.RenderControl(writer);

            #endregion

            #region Delete file

            if (!ReadOnly)
            {
                var link = new BaseHyperLink
                {
                    Url     = "javascript:void();",
                    OnClick = string.Format("RemoveListItem(this, '{0}', '{1}', '{2}'); return false;", ClientID, item.SelectedKey, item.Value),
                    ImgUrl  = Themes.IconUrlRemove,
                    ToolTip = Resources.SDeleteText,
                    Text    = Resources.SDeleteText,
                };
                HtmlGenerator.RenderHyperLink(writer, link);
            }

            #endregion

            if (!_dontRenderTd)
            {
                writer.RenderEndTag();//Td
            }
        }
Example #10
0
 protected override void RenderItem(HtmlTextWriter writer, ListControlItem item, BaseListDataBoundRenderEventArgs args)
 {
     throw new NotImplementedException();
 }
Example #11
0
        protected override void RenderItem(HtmlTextWriter writer, ListControlItem item, BaseListDataBoundRenderEventArgs args)
        {
            if (RenderOnlyText)
            {
                writer.Write(item.Text);
                return;
            }

            var checkBoxID = CheckBoxClientID(item);

            if (!string.IsNullOrEmpty(item.ToolTip))
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Title, item.ToolTip);
            }
            writer.AddStyleAttribute(HtmlTextWriterStyle.Width, args.Width);
            writer.RenderBeginTag(HtmlTextWriterTag.Td);

            #region checkbox

            if (!ReadOnly)
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Type, "checkbox");
                if (item.Selected)
                {
                    writer.AddAttribute(HtmlTextWriterAttribute.Value, "on");
                    writer.AddAttribute(HtmlTextWriterAttribute.Checked, "checked");
                }
                writer.AddAttribute(HtmlTextWriterAttribute.Id, checkBoxID);
                writer.AddAttribute(HtmlTextWriterAttribute.Name, CheckBoxUniqueID(item));
                writer.AddAttribute("CheckedValue", item.Value);
                if (!item.Enabled || !item.Selectable)
                {
                    writer.AddAttribute(HtmlTextWriterAttribute.Disabled, "disabled");
                }
                writer.RenderBeginTag(HtmlTextWriterTag.Input);
                writer.RenderEndTag();
            }

            #endregion

            RenderItemIcon(writer, item);

            if (string.IsNullOrEmpty(item.ReferenceValue))
            {
                RenderLabelItem(writer, item, args, checkBoxID);
            }
            else
            {
                RenderRefereceItem(writer, item, args);
            }

            writer.RenderEndTag();
        }
Example #12
0
        protected virtual void RenderLabelItem(HtmlTextWriter writer, ListControlItem item, BaseListDataBoundRenderEventArgs args, string checkBoxID)
        {
            writer.AddAttribute(HtmlTextWriterAttribute.For, checkBoxID);
            if (!item.Enabled)
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Disabled, "disabled");
            }
            writer.RenderBeginTag(HtmlTextWriterTag.Label);

            if (!string.IsNullOrEmpty(item.Text))
            {
                var text = HttpUtility.HtmlEncode(item.Text);
                if (!string.IsNullOrEmpty(text))
                {
                    writer.Write(text.Replace("\r\n", "<br />"));
                }
            }

            writer.RenderEndTag();
        }