Exemple #1
0
        //old
        //private static TagBuilder CreatLookupButton()
        //{
        //    TagBuilder button = new TagBuilder("span");
        //    button.MergeAttribute("id", string.Format("btnRP_{0}", Id));
        //    button.AddCssClass(string.Format("{0} {1}", StyleKind.RighSpace, StyleKind.Button));
        //    TagBuilder icon = new TagBuilder("span");
        //    icon.AddCssClass(StyleKind.Icons.LookUP);
        //    button.InnerHtml = icon.ToString() + ShowLookupScript();
        //    return button;
        //}



        //private static string ShowLookupScript()
        //{
        //    var script = @"<script>  $(document).ready(function () {  " +
        //       "$('#" + string.Format("btnRP_{0}", Id) + "').click(function () { var temp =$(this);  if( temp.attr('disabled')!== 'disabled') "
        //          + "LookUp.show('" + Title + "','lkp_" + Id + "_Div'" + @" );"
        //           + "else return false;    });} );</script>";
        //    return script;
        //}

        //----------------------------new
        private static TagBuilder CreatLookupButton(Lookup.Grid lookInfo)
        {
            TagBuilder button = new TagBuilder("span");

            button.MergeAttribute("id", string.Format("btnCr_{0}", Id));
            button.AddCssClass(string.Format("{0} {1}", StyleKind.RighSpace, StyleKind.Button));
            TagBuilder icon = new TagBuilder("span");

            icon.AddCssClass(StyleKind.Icons.LookUP);
            button.InnerHtml = icon.ToString() + ShowLookupScript(lookInfo);
            return(button);
        }
Exemple #2
0
        private static string ShowLookupScript(Lookup.Grid info)
        {
            var script = @"<script>  $(document).ready(function () {  " +
                         "$('#" + string.Format("btnCr_{0}", Id) + "').click(function () { var temp =$(this);  if( temp.attr('disabled')!== 'disabled') "
                         + string.Format("Lookup.loadGrid('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}',{9},{10}",
                                         info.Title,
                                         info.ViewModel,
                                         info.ViewInfoKey,
                                         info.LookupName,
                                         info.GridID,
                                         info.PropertyNameForDisplay,
                                         info.PropertyNameForValue,
                                         info.PropertyNameForBinding,
                                         info.UseMultiSelect,
                                         info.Width,
                                         info.Height
                                         ) + @" );"
                         + "else return false;    });} );</script>";

            return(script);
        }
Exemple #3
0
        public static MvcHtmlString LookUpCr <TModel>(this HtmlHelper helper, string id, string name, string title, GridInfo gridInfo,
                                                      string propertyNameForValue, string propertyNameForDisplay, string propertyNameForBinding, object htmlAttributes,
                                                      bool readOnly, Dictionary <string, object> lookupHtmlAttributes, ClientDependentFeature clientDependentFeature, params ValidationBase[] validationCr) where TModel : IViewModel, new()
        {
            Id = id;
            // Title = title;

            TagBuilder container = new TagBuilder("span");

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

            TagBuilder containerState = new TagBuilder("span");


            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 gridID = string.Format("lookupGrid_{0}", Id);
            ///we must new from static instance to set  info itself


            var info = gridInfo.DeepCopy();

            info.GridID = gridID;
            info.ClientDependentFeatures = clientDependentFeature;

            // gridInfo.GridID = gridID;

            //gridInfo.ClientDependentFeatures = clientDependentFeature;


            //var gridInfoKey = string.Format("{0}_{1}", gridInfo.GetHashCode(), gridInfo.GridID);
            var gridInfoKey = string.Format("{0}_{1}", gridInfo.GetHashCode(), gridID);


            AllGridLookups.TryAdd(gridInfoKey, info);

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

                LookupName = Id,

                GridID = info.GridID,

                ViewModel = typeof(TModel).AssemblyQualifiedName,

                // ViewInfoKey = viewInfoName,

                ViewInfoKey = gridInfoKey,

                UseMultiSelect = false,

                PropertyNameForDisplay = propertyNameForDisplay,

                PropertyNameForValue = propertyNameForValue,

                PropertyNameForBinding = propertyNameForBinding,

                ClientDependentFeatures = info.ClientDependentFeatures
            };

            //----create Lookup
            containerState.InnerHtml = textbox.ToHtmlString()

                                       + hiddenValue.ToString(TagRenderMode.SelfClosing)

                                       + CreatLookupButton(lookupInfo);

            container.InnerHtml = containerState.ToString();

            return(MvcHtmlString.Create(container.ToString()));
        }
Exemple #4
0
        public static MvcHtmlString LookUpCr <TModel>(this HtmlHelper helper, string id, string name, string title, GridInfo gridInfo
                                                      , string propertyNameForValue, string propertyNameForDisplay, string propertyNameForBinding, bool isMultiSelect, object htmlAttributes, bool readOnly
                                                      , Dictionary <string, object> lookupHtmlAttributes, ClientDependentFeature clientDependentFeature, 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");



            //-----multi select
            Kendo.Mvc.UI.Fluent.MultiSelectBuilder multiSelect = helper.MultiSelectCr(propertyNameForBinding, propertyNameForDisplay, propertyNameForValue, 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 gridID = string.Format("lookupGrid_{0}", Id);

            //gridInfo.GridID = gridID;

            //gridInfo.ClientDependentFeatures = clientDependentFeature;

            ////var gridInfoHashKey = gridInfo.GetHashCode();
            //// var gridInfohKey = new Guid();
            //var gridInfoKey = string.Format("{0}_{1}", gridInfo.GetHashCode(), gridInfo.GridID);
            //AllGridLookups.TryAdd(gridInfoKey, gridInfo);



            string gridID = string.Format("lookupGrid_{0}", Id);
            ///we must new from static instance to set  info itself


            var info = gridInfo.DeepCopy();

            info.GridID = gridID;
            info.ClientDependentFeatures = clientDependentFeature;

            // gridInfo.GridID = gridID;

            //gridInfo.ClientDependentFeatures = clientDependentFeature;


            //var gridInfoKey = string.Format("{0}_{1}", gridInfo.GetHashCode(), gridInfo.GridID);
            var gridInfoKey = string.Format("{0}_{1}", gridInfo.GetHashCode(), gridID);


            AllGridLookups.TryAdd(gridInfoKey, info);


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

                LookupName = Id,

                GridID = gridID,

                ViewModel = typeof(TModel).AssemblyQualifiedName,

                ViewInfoKey = gridInfoKey,

                UseMultiSelect = true,

                PropertyNameForDisplay = propertyNameForDisplay,

                PropertyNameForValue = propertyNameForValue,

                PropertyNameForBinding = propertyNameForBinding,

                ClientDependentFeatures = info.ClientDependentFeatures
            };

            containerState.InnerHtml = multiselectHtml
                                       + CreatLookupButton(lookupInfo);

            container.InnerHtml = containerState.ToString();



            return(MvcHtmlString.Create(container.ToString()));
        }