Ejemplo n.º 1
0
        public static MvcHtmlString TreeViewBoxCr <TModel>(this HtmlHelper helper, TreeInfo info, string name, TreeViewEventBuilder events
                                                           , bool hasCheckbox) where TModel : IViewModel, new()

        {
            var treeViewHtmlString = helper.TreeViewCr <TModel>(info, name, events, hasCheckbox).ToHtmlString();

            return(CreateToolBox <TModel>(helper, info, name, treeViewHtmlString));
        }
Ejemplo n.º 2
0
        public TreeViewDataSource(TreeInfo info, string name, dynamic modelValues)
        {
            this.ID = name;

            //  this._model = modelValues;

            this._dataSourceInfo = info.DataSource;

            initializeSchema();

            base.Type = null;

            base.Events = base.AssignDsEvents(_dataSourceInfo.DataSourceEvents ?? new Dictionary <DataSourceEvent, object>(), null);

            _dataSourceInfo.CrudCr.Read.Data = info.FunctionName;

            base.Transport = CreateTransportObject(_dataSourceInfo.CrudCr);
        }
Ejemplo n.º 3
0
        public static MvcHtmlString TreeViewCr <TModel>(this HtmlHelper helper, TreeInfo info, string name, TreeViewEventBuilder events, bool hasCheckBox) where TModel : IViewModel, new()
        {
            info.DataSource.ModelCr.ModelType = typeof(TModel);

            var initializer = DI.Current.Resolve <IJavaScriptInitializer>();

            info.Name = name;

            TreeView tree = new TreeView(helper.ViewContext, initializer, info, hasCheckBox);

            tree.Events = events.handler;

            tree.DataTextField = info.DataTextField;

            var builder = new TreeViewBuilder(tree);

            return(MvcHtmlString.Create(builder.ToHtmlString()));
        }
Ejemplo n.º 4
0
 public static MvcHtmlString LookUpCr <TModel>(this HtmlHelper helper, string id, string name, string title, TreeInfo treeInfo, string propertyNameForBinding, bool readOnly, bool isMultiSelect, object htmlAttributes) where TModel : IViewModel, new()
 {
     return(LookUpCr <TModel>(helper, id, name, title, treeInfo, propertyNameForBinding, isMultiSelect, htmlAttributes, readOnly, null, null));
 }
Ejemplo n.º 5
0
 public static MvcHtmlString LookUpRP <TModel>(this HtmlHelper helper, string id, string name, string title, TreeInfo treeInfo, string propertyNameForBinding, bool readOnly, bool isMultiSelect, Dictionary <string, object> lookupHtmlAttributes, params ValidationBase[] validationCr) where TModel : IViewModel, new()
 {
     return(LookUpCr <TModel>(helper, id, name, title, treeInfo, propertyNameForBinding, isMultiSelect, null, readOnly, lookupHtmlAttributes, validationCr));
 }
Ejemplo n.º 6
0
        public static MvcHtmlString LookUpCr <TModel>(this HtmlHelper helper, string id, string name, string title, TreeInfo treeInfo, string propertyNameForBinding, bool isMultiSelect,
                                                      object htmlAttributes, bool readOnly, Dictionary <string, object> lookupHtmlAttributes, params ValidationBase[] validationCr) where TModel : IViewModel, new()
        {
            Id = id;

            TagBuilder container = new TagBuilder("span");

            container.AddCssClass("rp-lookup");

            if (htmlAttributes != null)
            {
                var attributes = HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes);

                container.MergeAttributes(attributes);
            }

            TagBuilder containerState = new TagBuilder("span");

            //-----MultiSelect

            Kendo.Mvc.UI.Fluent.MultiSelectBuilder multiSelect = helper.MultiSelectCr(propertyNameForBinding, treeInfo.DataTextField, treeInfo.DataSource.ModelCr.ModelIdName, Kendo.Mvc.UI.FilterType.Contains);

            lookupHtmlAttributes = lookupHtmlAttributes ?? new Dictionary <string, object>();

            Dictionary <string, string> _htmlAttributes = null;

            if (validationCr != null && validationCr.Count() > 0)
            {
                _htmlAttributes = CreateValidationForlookup(lookupHtmlAttributes, validationCr);
            }

            else
            {
                _htmlAttributes = lookupHtmlAttributes.ToDictionary(t => t.Key, t => (string)t.Value);
            }

            if (readOnly)
            {
                _htmlAttributes.Add("readOnly", "true");
            }

            if (!string.IsNullOrEmpty(Id))
            {
                _htmlAttributes.Add("id", Id);
            }

            if (!string.IsNullOrEmpty(name))
            {
                _htmlAttributes.Add("name", name);
            }

            multiSelect.HtmlAttributes(_htmlAttributes.ToDictionary(t => t.Key, t => (object)t.Value));

            var multiSelectHtml = multiSelect.ToHtmlString();

            containerState.AddCssClass(multiSelectHtml.Contains("data-val-required") ? StyleKind.RequiredInput : StyleKind.OptionalInput);

            //string treeID = string.Format("lookupTree_{0}", Id);

            //treeInfo.Name = treeID;

            //var treeInfoHashKey = treeInfo.GetHashCode();

            //AllTreeLookups.TryAdd(treeInfoHashKey, treeInfo);

            string treeID = string.Format("lookupTree_{0}", Id);
            ///we must new from static instance to set  info itself
            var info = treeInfo.DeepCopy <TreeInfo>();

            info.Name = treeID;
            var treeInfoKey = string.Format("{0}_{1}", treeInfo.GetHashCode(), treeID);

            AllTreeLookups.TryAdd(treeInfoKey, info);


            var lookupInfo = new Lookup.Tree
            {
                Title = title,

                LookupName = Id,

                TreeID = treeID,
                // ViewModel = typeof(TModel).FullName,
                ViewModel = typeof(TModel).AssemblyQualifiedName,

                ViewInfoKey = treeInfoKey,

                UseMultiSelect = true,

                PropertyNameForDisplay = treeInfo.DataTextField,

                PropertyNameForValue = treeInfo.DataSource.ModelCr.ModelIdName,

                PropertyNameForBinding = propertyNameForBinding
            };


            //-----Create lookup----
            containerState.InnerHtml = multiSelectHtml + CreatLookupButton(lookupInfo);

            container.InnerHtml = containerState.ToString();

            container.InnerHtml = containerState.ToString();

            return(MvcHtmlString.Create(container.ToString()));
        }
Ejemplo n.º 7
0
 public static MvcHtmlString LookUpCr <TModel>(this HtmlHelper helper, string id, string title, TreeInfo treeInfo, string propertyNameForBinding) where TModel : IViewModel, new()
 {
     return(LookUpCr <TModel>(helper, id, string.Empty, title, treeInfo, propertyNameForBinding, null, false, null, null));
 }
Ejemplo n.º 8
0
 public static MvcHtmlString LookUpCr <TModel>(this HtmlHelper helper, string id, string name, string title, TreeInfo treeInfo, string propertyNameForBinding, Dictionary <string, object> lookupTextBoxHtmlAttributes) where TModel : IViewModel, new()
 {
     return(LookUpCr <TModel>(helper, id, name, title, treeInfo, propertyNameForBinding, null, false, lookupTextBoxHtmlAttributes, null));
 }
Ejemplo n.º 9
0
        public static MvcHtmlString LookUpCr <TModel>(this HtmlHelper helper, string id, string name, string title, TreeInfo treeInfo, string propertyNameForBinding
                                                      , object htmlAttributes, bool readOnly, Dictionary <string, object> lookupHtmlAttributes, params ValidationBase[] validationCr)
            where TModel : IViewModel, new()
        {
            Id = id;

            TagBuilder container = new TagBuilder("span");

            if (htmlAttributes != null)
            {
                var attributes = HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes);

                container.MergeAttributes(attributes);
            }

            TagBuilder containerState = new TagBuilder("span");

            //-----textbox
            MvcHtmlString textbox;

            lookupHtmlAttributes = lookupHtmlAttributes ?? new Dictionary <string, object>();

            //---value
            TagBuilder hiddenValue = new TagBuilder("input");

            hiddenValue.MergeAttribute("type", "hidden");

            hiddenValue.MergeAttribute("id", propertyNameForBinding);

            if (!string.IsNullOrEmpty(name))
            {
                hiddenValue.MergeAttribute("name", name);
            }

            hiddenValue.MergeAttribute("data-bind", string.Format("value:{0}", propertyNameForBinding));

            if (validationCr != null && validationCr.Count() > 0)
            {
                hiddenValue.MergeAttributes(CreateValidationForlookup(lookupHtmlAttributes, validationCr));
            }

            textbox = helper.TextBoxCr(Id, readOnly, lookupHtmlAttributes);

            //string treeID = string.Format("lookupTree_{0}", Id);

            //treeInfo.Name = treeID;

            //var treeInfoHashKey = treeInfo.GetHashCode();

            //AllTreeLookups.TryAdd(treeInfoHashKey, treeInfo);

            string treeID = string.Format("lookupTree_{0}", Id);
            ///we must new from static instance to set  info itself
            var info = treeInfo.DeepCopy <TreeInfo>();

            info.Name = treeID;
            var treeInfoKey = string.Format("{0}_{1}", treeInfo.GetHashCode(), treeID);

            AllTreeLookups.TryAdd(treeInfoKey, info);

            var lookupInfo = new Lookup.Tree
            {
                Title = title,

                LookupName = Id,

                TreeID = treeID,

                ViewModel = typeof(TModel).AssemblyQualifiedName,

                ViewInfoKey = treeInfoKey,

                UseMultiSelect = false,

                PropertyNameForDisplay = treeInfo.DataTextField,

                PropertyNameForBinding = propertyNameForBinding
            };


            //-----create lookup----
            containerState.InnerHtml = textbox.ToHtmlString()
                                       + hiddenValue
                                       + CreatLookupButton(lookupInfo);

            container.InnerHtml = containerState.ToString();

            return(MvcHtmlString.Create(container.ToString()));
        }
Ejemplo n.º 10
0
        private static MvcHtmlString CreateToolBox <TModel>(HtmlHelper helper, TreeInfo info, string treeName, string ComponentHtmlString, string templateName, int?width, int?height)
            where TModel : IViewModel
        {
            // var jsonModel = new ModelDescriptor(typeof(TModel)).ToJson();

            //  string serializedModel = new Kendo.Mvc.Infrastructure.JavaScriptInitializer().Serialize(jsonModel);

            TagBuilder boxBuilder = new TagBuilder("div");

            boxBuilder.AddCssClass(StyleKind.BoxBoarder);


            TagBuilder toolBarBuilder = new TagBuilder("div");

            toolBarBuilder.AddCssClass(StyleKind.TreeToolbar);


            if (!info.Operation.ReadOnly)
            {
                ElementAuthentication.UserAccessibleElement.DefineCrudActionAuthority(info.Operation, info.DataSource.CrudCr);
                if (info.Operation.Insertable)
                {
                    string insertScript = CreateTemplateScriptForCRUD(treeName, typeof(TModel).Name, "Insert" /*Constants.Insert*/, info.TemplateInfo, Enum.GetName(typeof(HttpVerbs), HttpVerbs.Post));

                    MvcHtmlString insertButton = helper.IconButtonCr("btnInsert_tree_" + treeName + "_ns", "Insert" /*Constants.Insert*/, string.Format("{0} {1}", StyleKind.CommandButton, "rp-tree-add")
                                                                     , StyleKind.Icons.Add, insertScript);

                    toolBarBuilder.InnerHtml += insertButton.ToHtmlString();
                }

                if (info.Operation.Updatable)
                {
                    string updateScript = CreateTemplateScriptForCRUD(treeName, typeof(TModel).Name, "Edit" /*Constants.Edit*/, info.TemplateInfo, Enum.GetName(typeof(HttpVerbs), HttpVerbs.Put));

                    MvcHtmlString editButton = helper.IconButtonCr("btnUpdate_tree_" + treeName + "_ns", "Edit" /*Constants.Edit*/, string.Format("{0} {1}", StyleKind.CommandButton, "rp-tree-edit")
                                                                   , StyleKind.Icons.Edit, updateScript);

                    toolBarBuilder.InnerHtml += editButton.ToHtmlString();
                }

                if (info.Operation.Removable)
                {
                    string deleteScript = CreateTemplateScriptForCRUD(treeName, typeof(TModel).Name, "Delete" /*Constants.Delete*/, info.TemplateInfo, Enum.GetName(typeof(HttpVerbs), HttpVerbs.Delete));

                    MvcHtmlString deletetButton = helper.IconButtonCr("btnDelete_tree_" + treeName + "_ns", "Delete" /*Constants.Delete*/, string.Format("{0} {1}", StyleKind.CommandButton, "rp-tree-delete")
                                                                      , StyleKind.Icons.Delete, deleteScript);

                    toolBarBuilder.InnerHtml += deletetButton.ToHtmlString();
                }
            }

            //------Refresh--------
            string refreshScript = "<script> $(document).ready( function(){$('#btnRefresh_tree_" + treeName + "_ns').click( function(){" +
                                   "TreeView.refresh(" + treeName + ");});" +
                                   "}); </script>";

            MvcHtmlString refreshButton = helper.IconButtonCr("btnRefresh_tree_" + treeName + "_ns", string.Format("{0} {1}", StyleKind.CommandButton, "rp-tree-refresh")
                                                              , StyleKind.Icons.Refresh, refreshScript);

            toolBarBuilder.InnerHtml += refreshButton.ToHtmlString();
            //-----------------

            //---------Help

            string helpScript = CreateTemplateScriptForCRUD(treeName, typeof(TModel).Name, "Help" /*Constants.Help*/, info.TemplateInfo, "Help");

            MvcHtmlString helpButton = helper.ImageLinkButtonCr("btnHelp_tree_" + treeName + "_ns", "Help" /* Constants.Help*/, "#", "HelpImageUrl"/*Constants.HelpImageUrl*/
                                                                , string.Format("{0} {1}", StyleKind.CommandButton, "rp-tree-Help"), helpScript);

            toolBarBuilder.InnerHtml += helpButton.ToHtmlString();
            //------------------

            TagBuilder emptyHeaderBuilder = new TagBuilder("div");

            emptyHeaderBuilder.AddCssClass(StyleKind.HeaderRow);
            var msg = string.Empty;

            _constantService.TryGetValue <string>("ThereIsntAnyData", out msg);
            emptyHeaderBuilder.SetInnerText(msg /*Messages.ThereIsntAnyData*/);


            boxBuilder.InnerHtml = toolBarBuilder.ToString() + emptyHeaderBuilder.ToString() + ComponentHtmlString;//+ globalTreeScript;

            return(MvcHtmlString.Create(boxBuilder.ToString()));
        }
Ejemplo n.º 11
0
 private static MvcHtmlString CreateToolBox <TModel>(HtmlHelper helper, TreeInfo info, string treeName, string ComponentHtmlString, int width, int height)
     where TModel : IViewModel
 {
     return(CreateToolBox <TModel>(helper, info, treeName, ComponentHtmlString, string.Empty, width, width));
 }
Ejemplo n.º 12
0
 public static MvcHtmlString TreeViewCr <TModel>(this HtmlHelper helper, TreeInfo info, string name, TreeViewEventBuilder events) where TModel : IViewModel, new()
 {
     return(TreeViewCr <TModel>(helper, info, name, events, false));
 }
Ejemplo n.º 13
0
 public static MvcHtmlString TreeViewCr(this HtmlHelper helper, TreeInfo info, string name, bool hasCheckBox)
 {
     return(TreeViewCr(helper, info, name, null, hasCheckBox));
 }
Ejemplo n.º 14
0
        //internal bool isPathHighlighted;

        public TreeView(ViewContext viewContext, Kendo.Mvc.Infrastructure.IJavaScriptInitializer initializer, TreeInfo info, bool hasCheckBox, ViewDataDictionary viewData = null)
            : base(viewContext, initializer)
        {
            this.Name = info.Name;

            this.DragAndDrop = false;

            this.Items = new LinkedObjectCollection <TreeViewItem>(null);

            this.SelectedIndex = -1;

            this.LoadOnDemand = true;

            this.AutoBind = info.AutoBind;

            dynamic vmValues = null;

            if (info.DataSource.ModelCr.ModelType.Equals(typeof(TreeViewModelBase)))
            {
                info.DataSource.ModelCr.ModelType = typeof(TreeViewModelBase);

                vmValues = new TreeViewModelBase();
            }

            else if (ViewData.Model != null)
            {
                vmValues = ViewData.Model;
            }

            this.DataSource = new TreeViewDataSource(info, this.Name, info.DataSource.ModelCr.ModelType);



            // this.DataSource = new TreeViewDataSource(info.DataSource, this.Name , ViewData.Model );

            if (hasCheckBox)
            {
                this.Checkboxes = new TreeViewCheckboxesSettings();
            }
            // this.SecurityTrimming = new Kendo.Mvc.UI.SecurityTrimming();
            //this.UrlGenerator = urlGenerator;
            //this.Authorization = authorization;
        }