Beispiel #1
0
        public MultipleDecodeItem(string code, IDecoder decoder, params object[] args)
        {
            fDecodeData = new MultipleDecoderData();
            QuoteStringList list  = QuoteStringList.FromString(code);
            var             items = list.CreateEnumerable();

            foreach (string item in items)
            {
                IDecoderItem dItem = decoder.Decode(item, args);
                fDecodeData.AddItem(dItem);
            }
            Name        = fDecodeData.ToJson();
            DisplayName = Name;
        }
Beispiel #2
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());
        }