private void AddItem(ListControlItem item, object dataItem)
        {
            if (GroupFields == null || GroupFields.Count == 0)
            {
                Items.Add(item);
                return;
            }
            var groupValues = GetGroupValues(dataItem);

            if (_lastGroups == null)
            {
                _lastGroups = new ListControlItem[GroupFields.Count];
                AddGroupItems(0, groupValues);
            }
            else
            {
                for (int i = 0; i < GroupFields.Count; i++)
                {
                    if ((groupValues[i] != null && groupValues[i].Equals(_lastGroupValues[i])) ||
                        (string.IsNullOrEmpty(groupValues[i]) && string.IsNullOrEmpty(_lastGroupValues[i])))
                    {
                        continue;
                    }
                    AddGroupItems(i, groupValues);
                    break;
                }
            }
            _lastGroups[GroupFields.Count - 1].Children.Add(item);
        }
 protected virtual void InitializeItem(ListControlItem item, object dataItem)
 {
     if (!string.IsNullOrEmpty(DataTextField))
     {
         item.Text = GetPropertyValue(dataItem, DataTextField, DataTextFormatString);
     }
     if (!string.IsNullOrEmpty(DataValueField))
     {
         item.Value = GetPropertyValue(dataItem, DataValueField, null);
     }
     if (!string.IsNullOrEmpty(this.DataReferenceValueField))
     {
         item.ReferenceValue = GetPropertyValue(dataItem, this.DataReferenceValueField, null);
     }
     if (!string.IsNullOrEmpty(DataToolTipField))
     {
         item.ToolTip = GetPropertyValue(dataItem, DataToolTipField, DataToolTipFormatString);
     }
     item.Enabled = string.IsNullOrEmpty(DataEnabledField) ||
                    Convert.ToBoolean(GetPropertyValue(dataItem, DataEnabledField, null));
     if (!string.IsNullOrEmpty(DataDeletedField))
     {
         item.Deleted = Convert.ToBoolean(GetPropertyValue(dataItem, DataDeletedField, null));
     }
     if (!string.IsNullOrEmpty(DataSelectedField))
     {
         item.Selected = Convert.ToBoolean(GetPropertyValue(dataItem, DataSelectedField, null));
     }
     if (!string.IsNullOrEmpty(DataSelectedKeyField))
     {
         item.SelectedKey = GetPropertyValue(dataItem, DataSelectedKeyField, null);
     }
 }
        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 RenderItems(HtmlTextWriter writer, ListControlItem item, BaseListDataBoundRenderEventArgs args)
        {
            var children = ReadOnly || ShowOnlySelected
                               ? item.Children.Where(r => r.AnySelected()).ToList()
                               : item.Children;

            RenderItems(writer, children, args);
        }
Beispiel #5
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();
        }
        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
            }
        }
Beispiel #7
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();
        }
        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());
        }
        private static UploadInfo GetResult(string fileName, string tableId, SYS_FileUpload sfu)
        {
            var fs = new FileSelector {
                ID = tableId,
            };
            var item = new ListControlItem {
                Value = sfu.id.ToString(), Text = fileName, Selected = true, Enabled = true,
            };

            return(new UploadInfo
            {
                FileName = fileName,
                ID = sfu.id,
                TableID = tableId,
                Html = fs.Render(item),
                Item = item,
            });
        }
Beispiel #10
0
        protected virtual void RenderItemIcon(HtmlTextWriter writer, ListControlItem item)
        {
            if (!item.Deleted)
            {
                return;
            }

            // todo: метод для динамического определения иконки
            var archiveIcon = string.IsNullOrEmpty(ArchiveIcon) ? Themes.IconUrlArchive : ArchiveIcon;

            writer.AddAttribute(HtmlTextWriterAttribute.Src, archiveIcon);
            writer.AddAttribute(HtmlTextWriterAttribute.Border, "0");
            // todo: метод для динамического определения сообщения
            var archiveMessage = string.IsNullOrEmpty(ArchiveMessage) ? Resources.SRowArchive : ArchiveMessage;

            writer.AddAttribute(HtmlTextWriterAttribute.Title, archiveMessage);
            writer.AddAttribute(HtmlTextWriterAttribute.Alt, archiveMessage);
            writer.RenderBeginTag(HtmlTextWriterTag.Img);
            writer.RenderEndTag();
        }
Beispiel #11
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();
        }
 private void AddGroupItems(int groupIndex, string[] groupValues)
 {
     _lastGroupValues = groupValues;
     for (int i = groupIndex; i < GroupFields.Count; i++)
     {
         var groupField = GroupFields[i];
         var group      = new ListControlItem
         {
             Children   = new List <ListControlItem>(),
             IsGroup    = true,
             Selectable = groupField.Selectable,
             Text       = string.IsNullOrEmpty(groupValues[i]) ? groupField.NullText : groupValues[i],
             Value      = "msc_" + Guid.NewGuid().ToString("N"),
         };
         group.HideGroup = string.IsNullOrEmpty(group.Text) && groupField.HideGroupIfValueNull;
         if (groupField.Collapsible && !group.HideGroup && Page != null)
         {
             var clientID = group.Value;
             var extender = new CollapsiblePanelExtender
             {
                 ID                = "cp_" + clientID,
                 BehaviorID        = "cpb_" + clientID,
                 Collapsed         = groupField.DefaultCollapced,
                 ExpandDirection   = CollapsiblePanelExpandDirection.Vertical,
                 CollapseControlID = clientID + "_Legend",
                 ExpandControlID   = clientID + "_Legend",
             };
             ExtenderAjaxControl.AddExtender(extender, clientID);
         }
         if (i == 0)
         {
             Items.Add(group);
         }
         else
         {
             _lastGroups[i - 1].Children.Add(group);
         }
         _lastGroups[i] = group;
     }
 }
 protected virtual void InitUpdateValues(IDictionary values, ListControlItem item)
 {
 }
 protected virtual void InitInsertValues(IDictionary values, ListControlItem item)
 {
 }
 protected virtual bool CheckNeedUpdate(ListControlItem item)
 {
     return(false);
 }
 protected abstract void RenderItem(HtmlTextWriter writer, ListControlItem item,
                                    BaseListDataBoundRenderEventArgs args);
Beispiel #17
0
 protected override bool CheckNeedUpdate(ListControlItem item)
 {
     return(UserControl.CheckNeedUpdate(item));
 }
Beispiel #18
0
 protected internal abstract string GetClientID(ListControlItem item);
Beispiel #19
0
 public abstract bool CheckNeedUpdate(ListControlItem item);
Beispiel #20
0
 public abstract void InitUpdateValues(IDictionary values, ListControlItem item);
Beispiel #21
0
 protected override void InitInsertValues(IDictionary values, ListControlItem item)
 {
     base.InitInsertValues(values, item);
     UserControl.InitInsertValues(values, item);
 }
Beispiel #22
0
 protected override void InitDeleteValues(IDictionary keys, ListControlItem item)
 {
     base.InitDeleteValues(keys, item);
     UserControl.InitDeleteValues(keys, item);
 }
Beispiel #23
0
 protected override void InitializeItem(ListControlItem item, object dataItem)
 {
     base.InitializeItem(item, dataItem);
     UserControl.InitializeItem(item, dataItem);
 }
 protected virtual void InitDeleteValues(IDictionary keys, ListControlItem item)
 {
     keys[DataSelectedKeyField] = item.SelectedKey;
 }
 protected virtual void InitValues(IDictionary values, ListControlItem item)
 {
     values[DataValueField] = item.Value;
 }
Beispiel #26
0
 public abstract void InitInsertValues(IDictionary values, ListControlItem item);
        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
            }
        }
Beispiel #28
0
 public abstract void InitDeleteValues(IDictionary keys, ListControlItem item);
Beispiel #29
0
 protected override void InitInsertValues(System.Collections.IDictionary values, ListControlItem item)
 {
     base.InitInsertValues(values, item);
     WebInitializer.Initialize();
     using (var db = new DBUploadFilesDataContext(SpecificInstances.DbFactory.CreateConnection()))
     {
         var row = db.SYS_FileUploads.
                   FirstOrDefault(r => r.id == Convert.ToInt64(item.Value) && r.PersonSID == User.GetSID());
         if (row != null)
         {
             values[FileDataFieldName] = row.data;
             values[FileFieldName]     = row.dataFileName;
         }
     }
 }
Beispiel #30
0
 protected override void RenderItem(HtmlTextWriter writer, ListControlItem item, BaseListDataBoundRenderEventArgs args)
 {
     throw new NotImplementedException();
 }