Beispiel #1
0
        public static string HiddenKey(INormalTableData table, IFieldValueProvider provider, bool needId)
        {
            TkDebug.AssertArgumentNull(table, "table", null);

            var keys = from item in table.HiddenList.Union(table.DataList)
                       where item.IsKey
                       select item;
            StringBuilder        builder     = new StringBuilder();
            HtmlAttributeBuilder attrBuilder = new HtmlAttributeBuilder();

            foreach (Tk5FieldInfoEx item in keys)
            {
                attrBuilder.Clear();
                string value = provider == null ? string.Empty : provider[item.NickName].ToString();
                attrBuilder.Add("value", value);
                attrBuilder.Add("type", "hidden");
                string name = "OLD_" + item.NickName;
                if (needId)
                {
                    attrBuilder.Add("id", name);
                }
                attrBuilder.Add("name", name);

                builder.AppendFormat("<input {0}/>", attrBuilder.CreateAttribute());
                builder.AppendLine();
            }

            return(builder.ToString());
        }
Beispiel #2
0
        private static string CreateRowOperator(IFieldValueProvider row, HtmlAttributeBuilder attrBuilder, Operator operRow)
        {
            string caption    = operRow.Caption;
            string urlContent = operRow.Content;

            if (string.IsNullOrEmpty(urlContent))
            {
                return(string.Format(ObjectUtil.SysCulture, "<li>{0}</li>", caption));
            }
            else
            {
                attrBuilder.Clear();
                attrBuilder.Add("href", "#");
                string info = operRow.Info ?? string.Empty;
                bool   isJs = info.Contains("JS");
                if (isJs)
                {
                    string js = "javascript:" + HtmlCommonUtil.ResolveString(row, urlContent);
                    attrBuilder.Add("onClick", js);
                }
                else
                {
                    string attrUrl;
                    if (info.Contains("Dialog"))
                    {
                        string dialogTitle = HtmlCommonUtil.ResolveString(row, operRow.DialogTitle);
                        attrBuilder.Add("data-title", dialogTitle);
                        attrUrl = "data-dialog-url";
                    }
                    else if (info.Contains("AjaxUrl"))
                    {
                        attrUrl = "data-ajax-url";
                    }
                    else
                    {
                        attrUrl = "data-url";
                    }
                    attrBuilder.Add(attrUrl, HtmlUtil.ParseLinkUrl(row, urlContent));
                    string dataConfirm = operRow.ConfirmData;
                    if (!string.IsNullOrEmpty(dataConfirm))
                    {
                        attrBuilder.Add("data-confirm", dataConfirm);
                    }
                }
                if (info.Contains("_blank"))
                {
                    attrBuilder.Add("data-target", "_blank");
                }
                return(string.Format(ObjectUtil.SysCulture, "<li><a {0}>{1}</a></li>",
                                     attrBuilder.CreateAttribute(), caption));
            }
        }
Beispiel #3
0
        private static string InternalMultiEasySearch(Tk5FieldInfoEx field, string nickName,
                                                      IFieldValueProvider row, bool needId)
        {
            HtmlAttributeBuilder textBuilder = new HtmlAttributeBuilder();

            textBuilder.Add("type", "text");
            textBuilder.Add("data-regName", field.Decoder.RegName);
            AddInputAttribute(field, textBuilder, false);
            AddNormalAttribute(field, textBuilder, nickName, needId);
            SimpleFieldDecoder decoder = field.Decoder as SimpleFieldDecoder;

            if (decoder != null && decoder.RefFields != null)
            {
                EasySearchRefConfig[] config = decoder.RefFields.ToArray();
                textBuilder.Add("data-refFields", config.WriteJson(WriteSettings.Default));
            }

            StringBuilder multiItems  = new StringBuilder();
            string        decodeValue = row[DecoderConst.DECODER_TAG + nickName].ToString();

            if (string.IsNullOrEmpty(decodeValue))
            {
                multiItems.AppendFormat(Html.MultiEasySearchItem, "hidden", string.Empty, string.Empty);
            }
            else
            {
                MultipleDecoderData  data          = MultipleDecoderData.ReadFromString(decodeValue);
                HtmlAttributeBuilder decodeBuilder = new HtmlAttributeBuilder();
                foreach (var item in data)
                {
                    decodeBuilder.Clear();
                    decodeBuilder.Add("data-id", item.Value);
                    decodeBuilder.Add("data-name", item.Name);

                    multiItems.AppendFormat(Html.MultiEasySearchItem, "multi-item",
                                            item.Name, decodeBuilder.CreateAttribute());
                }
            }

            string easyUrl   = "c/source/C/EasySearch".AppVirutalPath();
            string dialogUrl = ("c/~source/C/EasySearchRedirect?RegName="
                                + field.Decoder.RegName).AppVirutalPath();

            return(string.Format(ObjectUtil.SysCulture, Html.MultipleEasySearch,
                                 multiItems, textBuilder.CreateAttribute(), ERROR_LABEL,
                                 StringUtil.EscapeHtmlAttribute(easyUrl), StringUtil.EscapeHtmlAttribute(dialogUrl)));
        }
Beispiel #4
0
        public static string CheckBoxList(this Tk5FieldInfoEx field, IFieldValueProvider row, bool needId)
        {
            TkDebug.AssertArgumentNull(field, "field", null);
            TkDebug.AssertArgumentNull(row, "row", null);

            TkDebug.AssertNotNull(field.Decoder, "CheckBoxList控件需要配置Decoder", field);
            var           codeTable = row.GetCodeTable(field.Decoder.RegName);
            StringBuilder options   = new StringBuilder();

            if (codeTable != null)
            {
                HtmlAttributeBuilder divBuilder = new HtmlAttributeBuilder();
                AddNormalAttribute(field, divBuilder, field.NickName, needId, true);
                divBuilder.Add("data-control", "CheckBoxList");

                HtmlAttributeBuilder builder = new HtmlAttributeBuilder();
                //builder.Add("type", "radio");
                //builder.Add("name", field.NickName);
                //builder.Add("class", "radio-center");

                string          value      = row[field.NickName].ToString();
                QuoteStringList quoteValue = QuoteStringList.FromString(value);
                options.AppendFormat(ObjectUtil.SysCulture, "<div {0}>\r\n", divBuilder.CreateAttribute());
                foreach (var codeRow in codeTable)
                {
                    builder.Clear();
                    string codeValue = codeRow.Value;
                    builder.Add("value", codeValue);
                    if (quoteValue.Contains(codeValue))
                    {
                        builder.Add((HtmlAttribute)"checked");
                    }
                    options.AppendFormat(ObjectUtil.SysCulture, Html.CheckBoxListItem,
                                         builder.CreateAttribute(), codeRow.Name);
                }
                options.Append("</div>").AppendLine(ERROR_LABEL);
            }
            return(options.ToString());
        }