public virtual CellWriter RadioBoxCell <T>(IHtmlHelper <T> helper, string field, string rowIndex, string property, bool asArray, string changeFunction, object cellAttributes, object inputAttr, string listItem, string classes)
        {
            var writer = new CellWriter(helper);

            writer.Initialize(null, null, cellAttributes, inputAttr, classes);

            string lItem = helper.GetModelName() + (listItem != null ? "." + listItem : null);
            string type  = "checkbox";

            if (asArray)
            {
                writer.InputModel.MemberName = writer.InputModel.NgModelName + ".Tag.selected";
            }
            else
            {
                type = "radio";
                writer.InputModel.MemberName            = writer.InputModel.NgModelName + "." + property;
                writer.InputModelExtraAttrs.calc__value = rowIndex;
            }

            writer.InputModel           = writer.InputModel.GetCheckInput(null, null, false, lItem, type);
            writer.InputModel.FieldName = "'" + field + "'";

            if (changeFunction != null)
            {
                writer.InputModelExtraAttrs.evnt__change = changeFunction;
            }
            else if (asArray)
            {
                writer.InputModelExtraAttrs.evnt__change = helper.GetModelName() + $".Tag.SelectOnly({property})";
            }
            return(writer);
        }
Exemple #2
0
 public Worksheet(Stream stream, SpreadsheetBuffer buffer)
 {
     _stream           = stream;
     _buffer           = buffer;
     _cellWriter       = new CellWriter(buffer);
     _dataCellWriter   = new DataCellWriter(buffer);
     _styledCellWriter = new StyledCellWriter(buffer);
     _nextRowIndex     = 1;
 }
        public static IHtmlContent DragHeaderCell <T>(
            this IHtmlHelper <T> helper,
            string tableName,
            string width          = null,
            object cellAttributes = null)
        {
            var        Provider = helper.GetService <IMoldsterTableHelper>();
            CellWriter writer   = Provider.DragHeaderCell <T>(helper, tableName, width, cellAttributes);

            return(writer.WriteHeaderCell());
        }
        public static IHtmlContent LinkCell <T, TValue>(
            this IHtmlHelper <T> helper,
            Expression <Func <T, TValue> > exp,
            string url,
            bool blank            = true,
            object cellAttributes = null,
            object linkAttributes = null,
            string pipe           = null)
        {
            var        Provider = helper.GetService <IMoldsterTableHelper>();
            CellWriter writer   = Provider.LinkCell <T, TValue>(helper, exp, url, blank, cellAttributes, linkAttributes, pipe);

            return(writer.Write(InputControls.Label));
        }
        public static IHtmlContent HeaderCell <T, TValue>(
            this IHtmlHelper <T> helper,
            Expression <Func <T, TValue> > exp,
            string width             = null,
            bool ignoreAccessibility = false,
            object cellAttributes    = null,
            bool?sorting             = null)
        {
            var Provider = helper.GetService <IMoldsterTableHelper>();

            sorting = sorting ?? helper.GetTheme().SortingInTables;
            CellWriter wt = Provider.HeaderCell(helper, exp, width, ignoreAccessibility, cellAttributes, sorting.Value);

            return(wt.WriteHeaderCell());
        }
        public static IHtmlContent TextBoxCell <T, TValue>(
            this IHtmlHelper <T> helper,
            Expression <Func <T, TValue> > exp,
            string textBoxType         = "text",
            IValidationCollection coll = null,
            object cellAttributes      = null,
            object inputAttr           = null,
            string classes             = "",
            string rowIndex            = null,
            bool localizable           = false)
        {
            var        Provider = helper.GetService <IMoldsterTableHelper>();
            CellWriter wt       = Provider.TextBoxCell(helper, exp, textBoxType, coll, cellAttributes, inputAttr, classes, rowIndex, localizable);

            return(wt.Write(InputControls.TextBox));
        }
        public static IHtmlContent RadioBoxCell <T>(this IHtmlHelper <T> helper,
                                                    string field,
                                                    string rowIndex,
                                                    string property,
                                                    bool asArray          = true,
                                                    string changeFunction = null,
                                                    object cellAttributes = null,
                                                    object inputAttr      = null,
                                                    string listItem       = "Tag",
                                                    string classes        = "")
        {
            var        Provider = helper.GetService <IAngularTablesHelper>();
            CellWriter mod      = Provider.RadioBoxCell(helper, field, rowIndex, property, asArray, changeFunction, cellAttributes, inputAttr, listItem, classes);

            return(mod.Write(InputControls.CheckBoxCell));
        }
        public static IHtmlContent CheckBoxCell <T>(
            this IHtmlHelper <T> helper,
            string field,
            string rowIndex,
            string listName,
            string ngModel        = "Tag.selected",
            string changeFunction = null,
            object cellAttributes = null,
            object inputAttr      = null,
            string listItem       = "Tag",
            string classes        = "")
        {
            var        Provider = helper.GetService <IMoldsterTableHelper>();
            CellWriter mod      = Provider.CheckBoxCell(helper, field, rowIndex, listName, ngModel, changeFunction, cellAttributes, inputAttr, listItem, classes);

            return(mod.Write(InputControls.CheckBoxCell));
        }
        public static IHtmlContent CalendarCell <T, TValue>(
            this IHtmlHelper <T> helper,
            Expression <Func <T, TValue> > exp,
            CalendarTypes rangeType = CalendarTypes.PastAndFuture,
            Calendars cals          = Calendars.Greg,
            DateRange range         = null,
            bool required           = false,
            object cellAttributes   = null,
            object inputAttr        = null,
            string classes          = "",
            string rowIndex         = null)
        {
            var        Provider = helper.GetService <IMoldsterTableHelper>();
            CellWriter wt       = Provider.CalendarCell(helper, exp, rangeType, cals, range, required, cellAttributes, inputAttr, classes, rowIndex);

            return(wt.Write(InputControls.CalendarTextBox));
        }
        public virtual CellWriter TextCell <T, TValue>(IHtmlHelper <T> helper, Expression <Func <T, TValue> > exp, string pipe, object cellAttributes)
        {
            using (var writer = new CellWriter(helper))
            {
                writer.UseExpression(exp);
                writer.Initialize(null, null, cellAttributes, null);

                pipe = pipe == null ? "" : " | " + pipe;
                if (pipe.Contains("translate"))
                {
                    writer.InputModel.NgModelName = "'Words.'+" + writer.InputModel.NgModelName;
                }

                writer.InputModel.MemberName += pipe;
                return(writer);
            }
        }
        public static IHtmlContent AutoCompleteSelectCell <T, TValue>(
            this IHtmlHelper <T> helper,
            Expression <Func <T, TValue> > exp,
            Lister source,
            string displayMember,
            string valueMember    = null,
            bool required         = false,
            bool multi            = false,
            bool nullable         = false,
            object cellAttributes = null,
            object inputAttr      = null,
            string classes        = "")
        {
            var        Provider = helper.GetService <IMoldsterTableHelper>();
            CellWriter wt       = Provider.AutoCompleteSelectCell(helper, exp, source, displayMember, valueMember, required, multi, nullable, cellAttributes, inputAttr, classes);

            return(wt.Write(InputControls.Select_Searchable));
        }
        public virtual CellWriter CheckBoxCell <T>(IHtmlHelper <T> helper, string field, string rowIndex, string listName, string ngModel, string changeFunction, object cellAttributes, object inputAttr, string listItem, string classes)
        {
            var writer = new CellWriter(helper);

            string lItem = helper.GetModelName() + (listItem != null ? "." + listItem : "");

            writer.Initialize(null, null, cellAttributes, inputAttr, classes);
            writer.InputModel            = writer.InputModel.GetCheckInput(null, null, false, lItem);
            writer.InputModel.MemberName = helper.GetModelName() + "." + ngModel;
            writer.InputModel.FieldName  = "'" + field + "'+" + rowIndex;
            helper.AddText(StringType.Word, field);
            if (changeFunction != null)
            {
                writer.InputModelExtraAttrs.evnt__change = changeFunction;
            }
            else if (listName != null)
            {
                writer.InputModelExtraAttrs.evnt__change = helper.GetModelName() + $".Tag.ApplyTo({listName})";
            }

            return(writer);
        }
 internal void ForEachValue(string newNumberFormat, CellWriter cellDelegate)
 {
     if (_areas == null)
         return;
     foreach (var area in _areas) {
         Undo.AddUndoArea(area.Range);
         for (var r = 1; r <= area.NbRow; r++) {
             if (area.HiddenRows[r]) continue;
             for (var c = 1; c <= area.NbCol; c++) {
                 if (area.HiddenCols[c] || (!_withNullCells && area.Data[r, c] == null)) continue;
                 try {
                     cellDelegate(ref area.Data[r, c]);
                 } catch (Exception ex) {
                     ex.Data.Add(ex.Data.Count.ToString(), area.Data[r, c] == null ? null : "CellType: " + area.Data[r, c].GetType().ToString());
                     ex.Data.Add(ex.Data.Count.ToString(), area.Data[r, c] == null ? null : "CellValue: " + area.Data[r, c].ToString());
                     ex.Data.Add(ex.Data.Count.ToString(), "NumberFormat: " + newNumberFormat);
                     throw;
                 }
             }
         }
         if (newNumberFormat != null && (area.Range.NumberFormat is System.DBNull || (string)area.Range.NumberFormat != newNumberFormat))
             area.Range.NumberFormat = newNumberFormat;
         area.Range.Value = area.Data;
     }
 }
 internal static void AddDataToRange(Excel.Range range, int nbrow, string numberFormat, CellWriter cellDelegate)
 {
     var array = ExcelArray<object>.Create(nbrow, 1);
     for (int r = 1; r <= nbrow; r++)
         cellDelegate(ref array[r, 1]);
     CellsOperator.AddDataToRange(range, array, numberFormat);
 }