Exemple #1
0
        private void InitializeEditors()
        {
            ViewContext.HttpContext.Items["$SelfInitialize$"] = true;

            var dataItem = Editing.DefaultDataItem();

            var htmlHelper = new GridHtmlHelper <T>(ViewContext, DataKeyStore);

            if (Editing.Mode != GridEditMode.InLine && Editing.Mode != GridEditMode.InCell)
            {
                var container = new HtmlElement("div").AddClass(UIPrimitives.Grid.InFormContainer);

                htmlHelper.EditorForModel(dataItem, Editing.TemplateName, Columns.OfType <IGridForeignKeyColumn>().Select(c => c.SerializeSelectList), Editing.AdditionalViewData).AppendTo(container);

                EditorHtml = container.InnerHtml;
            }
            else
            {
                var cellBuilderFactory = new GridCellBuilderFactory();


                VisibleColumns.Each(column =>
                {
                    var cellBuilder = cellBuilderFactory.CreateEditCellBuilder(column, htmlHelper);

                    var editor = cellBuilder.CreateCell(dataItem);

                    column.EditorHtml = editor.InnerHtml;
                });
            }

            ViewContext.HttpContext.Items.Remove("$SelfInitialize$");
        }
Exemple #2
0
        private void InitializeEditors()
        {
            var skip         = ViewContext.HttpContext.Items["$SelfInitialize$"] != null && (bool)ViewContext.HttpContext.Items["$SelfInitialize$"] == true;
            var popupSlashes = new Regex("(?<=data-val-regex-pattern=\")([^\"]*)", RegexOptions.Multiline);

            ViewContext.HttpContext.Items["$SelfInitialize$"] = true;

            var dataItem = Editable.DefaultDataItem();

            var htmlHelper = new GridHtmlHelper <T>(ViewContext, DataKeyStore);

            if (Editable.Mode != GridEditMode.InLine && Editable.Mode != GridEditMode.InCell)
            {
                var container = new HtmlElement("div").AddClass(UIPrimitives.Grid.InFormContainer);

                htmlHelper.EditorForModel(dataItem, Editable.TemplateName, Columns.OfType <IGridForeignKeyColumn>().Select(c => c.SerializeSelectList), Editable.AdditionalViewData).AppendTo(container);

                EditorHtml = popupSlashes.Replace(container.InnerHtml, match =>
                {
                    return(match.Groups[0].Value.Replace("\\", IsInClientTemplate ? "\\\\\\\\" : "\\\\"));
                });
            }
            else
            {
                var cellBuilderFactory = new GridCellBuilderFactory();


                VisibleColumns.Each(column =>
                {
                    var cellBuilder = cellBuilderFactory.CreateEditCellBuilder(column, htmlHelper);
                    var editor      = cellBuilder.CreateCell(dataItem);
                    var editorHtml  = editor.InnerHtml;
                    if (IsInClientTemplate)
                    {
                        editorHtml = popupSlashes.Replace(editorHtml, match =>
                        {
                            return(match.Groups[0].Value.Replace("\\", "\\\\"));
                        });
                    }
                    column.EditorHtml = editorHtml;
                });
            }

            if (!skip)
            {
                ViewContext.HttpContext.Items.Remove("$SelfInitialize$");
            }
        }