Esempio n. 1
0
        public override void Process(TagHelperContext context, TagHelperOutput output)
        {
            output.TagName = "div";
            output.Content.Clear();
            string id = "tree";

            if (Id.IsPresent())
            {
                id = $"tree-{Id}";
            }
            JsTree tree = new JsTree(_dataAccessor, _rbacService, _applicationContext, id);

            tree.SetAsync(IsAsync);
            if (IsOrgdept)
            {
                tree.IsOrgDept();
            }
            if (GetUrl.IsPresent())
            {
                tree.SetUrl(GetUrl);
            }
            if (EditUrl.IsPresent())
            {
                tree.SetEditUrl(EditUrl);
            }
            if (JsonData.IsPresent())
            {
                tree.SetJsonData(JsonData);
            }
            if (TreeMode != null)
            {
                tree.SetTreeModel(TreeMode);
            }
            if (OnOpenNoded.IsPresent())
            {
                tree.OnOpenNodedEvent(OnOpenNoded);
            }
            if (OnLoaded.IsPresent())
            {
                tree.OnLoadedEvent(OnLoaded);
            }
            tree.SetPluginDnd(PluginDnd);
            tree.SetPluginCheckBox(PluginCheckbox);
            output.Content.AppendHtml(tree.ToString());
        }
Esempio n. 2
0
        public override void Process(TagHelperContext context, TagHelperOutput output)
        {
            QuerySet querySet = GridModel.QuerySet;

            output.TagName = "div";
            output.Content.Clear();
            string id = GridModel.JqgridId;

            if (Id.IsPresent())
            {
                id = Id;
            }
            this.Id = $"grid-{id}";
            string pager = $"pager-{id}";
            Grid   grid  = new Grid(_dbContext, _rbacService, _applicationContext, _multiLang, _env, this.Id);

            if (Url.IsPresent())
            {
                grid.SetUrl(Url);
            }
            else
            {
                if (IsTreeGrid)
                {
                    grid.SetUrl($"{ _applicationContext.BaseUrl }/Core/Api/TreeDataList");
                }
                else
                {
                    grid.SetUrl($"{ _applicationContext.BaseUrl }/Core/Api/DataList");
                }
            }
            if (EditUrl.IsPresent())
            {
                grid.SetEditUrl(EditUrl);
            }
            else
            {
                if (InlineFormEnabled)
                {
                    grid.SetEditUrl("clientArray");
                }
                else
                {
                    grid.SetEditUrl($"{_applicationContext.BaseUrl}/Core/Api/Inline/Persistence?from=grid");
                }
            }
            if (Caption.IsPresent())
            {
                grid.SetCaption(Caption);
            }
            if (AttachColumn != null)
            {
                grid.AddColumn(AttachColumn);
            }
            if (ExtraData != null)
            {
                grid.SetExtraData(ExtraData);
            }
            if (AttachColumns != null && AttachColumns.Any())
            {
                grid.AddColumns(AttachColumns);
            }

            grid.SetLogicDelete(LogicDelete);
            //鉴权列
            if (RegisterAuthority)
            {
                string cols = GetColumnPermission(querySet);
                if (cols.IsPresent())
                {
                    querySet.QueryCols = cols;
                }
            }
            grid.SetQueryOption(querySet);
            //获取数据时ajax post数据
            grid.SetPostData(new { QuerySet = querySet });
            //鉴权操作
            if (RegisterAuthority)
            {
                string authorize = AuthenticationButton(querySet);
                //设置操作
                SetGirdOper(grid, authorize);
            }
            else
            {
                SetGridDefaultOper(grid);
            }
            grid.SetAutoWidth(AutoWidth);
            grid.SetDataType(SourceType);
            grid.SetViewRecords(ViewRecords);
            grid.SetShrinkToFit(ShrinkFit);
            grid.SetColMenu(ColMenu);
            if (Height > 0)
            {
                grid.SetHeight(Height);
            }
            if (Wrapper.IsPresent())
            {
                string[] wrapper = Wrapper.Split(',');
                if (wrapper.Length > 1)
                {
                    grid.SetInsideTabControl($"{wrapper[0]}", $"{wrapper[1]}");
                }
                else
                {
                    grid.SetInsideElement(Wrapper);
                }
            }
            else
            {
                grid.SetInsideWidget();
            }
            if (GridModel.IsMulti)
            {
                grid.SetMultiSelect(true);
                //grid.SetMultiBoxOnly(true);
            }
            else
            {
                if (MultiSelect)
                {
                    grid.SetMultiSelect(MultiSelect);
                }
                if (MultiBoxOnly)
                {
                    grid.SetMultiBoxOnly(MultiBoxOnly);
                }
            }
            if (RowNum != 10)
            {
                grid.SetRowNum(RowNum);
            }
            grid.SetRowNumbers(RowNumbers);
            if (InlineFormEnabled || InlineGridEnabled)
            {
                grid.SetEditRowModel(EditRowModel.Inline);
            }
            grid.SetFooterRow(FooterRow);
            grid.SetUserDataOnFooter(UserdataFooter);
            if (IsTreeGrid)
            {
                if (ExpandColumn.IsPresent())
                {
                    grid.SetExpandColumn(ExpandColumn);
                }
                grid.EnableTreeGrid();
            }
            if (OnGridComplete.IsPresent())
            {
                if (OnGridComplete.Contains("("))
                {
                    grid.OnGridComplete($"{OnGridComplete};");
                }
                else
                {
                    grid.OnGridComplete($"{OnGridComplete}();");
                }
            }
            if (OnDblclickRow.IsPresent())
            {
                grid.OnDblClickRow(OnDblclickRow);
            }
            if (OnFormInitAdd.IsPresent())
            {
                if (OnFormInitAdd.Contains("("))
                {
                    grid.OnAddAfterInitDataForm($"{OnFormInitAdd};");
                }
                else
                {
                    grid.OnAddAfterInitDataForm($"{OnFormInitAdd}();");
                }
            }
            if (OnFormInitEdit.IsPresent())
            {
                if (OnFormInitEdit.Contains("("))
                {
                    grid.OnEditAfterInitDataForm($"{OnFormInitEdit};");
                }
                else
                {
                    grid.OnEditAfterInitDataForm($"{OnFormInitEdit}();");
                }
            }
            if (OnSelectRow.IsPresent())
            {
                if (OnSelectRow.Contains("("))
                {
                    grid.OnSelectRow($"{OnSelectRow};");
                }
                else
                {
                    grid.OnSelectRow($"{OnSelectRow}(rowid, status);");
                }
            }

            if (SearchToolbar)
            {
                grid.SetSearchToolbar(SearchToolbar);
            }
            if (SubgridRowexpanded.IsPresent())
            {
                grid.SetSubGridRowExpanded(SubgridRowexpanded);
            }
            if (GroupHeaders != null && GroupHeaders.Any())
            {
                grid.SetGroupHeaders(GroupHeaders);
            }
            grid.SetPager(pager);

            output.Content.AppendHtml(grid.ToString());
        }