public string DisplayValue(object value, Tk5FieldInfoEx field, IFieldValueProvider rowValue)
        {
            TkDebug.AssertArgumentNull(field, "field", this);

            if (DisplayUtil.IsNull(value))
            {
                return(string.Empty);
            }

            string result            = DisplayUtil.GetRowDecoderValue(rowValue, field.NickName).ConvertToString();
            MultipleDecoderData data = MultipleDecoderData.ReadFromString(result);

            return(string.Join(", ", data));
        }
Beispiel #2
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 #3
0
        // 有DataTable生成Excel
        private static void DataTableExport(ExportExcelPageMaker configData,
                                            Dictionary <string, ICellStyle> contentStyles, ISheet sheet, DataTable dataTable)
        {
            int rowIndex = 1;

            foreach (DataRow row in dataTable.Rows)
            {
                IRow dataRow     = sheet.CreateRow(rowIndex);
                int  columnIndex = 0;
                foreach (Tk5FieldInfoEx fieldInfo in configData.fMetaData.Table.TableList)
                {
                    ICell cell = dataRow.CreateCell(columnIndex);

                    if (fieldInfo != null)
                    {
                        string             strValue = string.Empty;
                        Tk5ExtensionConfig ex       = fieldInfo.Extension;
                        SimpleFieldControl sfctrl   = fieldInfo.InternalControl;
                        if (fieldInfo.Decoder == null || fieldInfo.Decoder.Type == DecoderType.None)
                        {
                            strValue = (row[fieldInfo.NickName]).ToString();

                            if (!string.IsNullOrEmpty(strValue))
                            {
                                if (sfctrl != null && sfctrl.SrcControl == ControlType.CheckBox)
                                {
                                    if ((ex != null && strValue == ex.CheckValue) ||
                                        (ex == null && strValue == "1"))
                                    {
                                        cell.SetCellValue("√");
                                    }
                                }
                                else
                                {
                                    CellPadding(strValue, cell, fieldInfo);
                                }
                            }
                        }
                        else
                        {
                            strValue = row[fieldInfo.NickName + "_Name"].ToString();

                            if (!string.IsNullOrEmpty(strValue))
                            {
                                if (sfctrl != null &&
                                    (sfctrl.SrcControl == ControlType.CheckBoxList ||
                                     sfctrl.SrcControl == ControlType.MultipleEasySearch))
                                {
                                    MultipleDecoderData data = MultipleDecoderData.ReadFromString(strValue);
                                    cell.SetCellValue(string.Join(", ", data));
                                }
                                else
                                {
                                    cell.SetCellValue(strValue);
                                }
                            }
                        }
                        cell.CellStyle = contentStyles[fieldInfo.NickName];
                    }
                    columnIndex++;
                }
                rowIndex++;
            }
        }