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())); }
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())); }
public static MvcHtmlString LookUpCr <TModel>(this HtmlHelper helper, string id, string title, GridInfo gridInfo, string propertyNameForValue, string propertyNameForDisplay, string propertyNameForBinding, bool isMultiSelect, bool readOnly, ClientDependentFeature clientDependentFeature) where TModel : IViewModel, new() { return(LookUpCr <TModel>(helper, id, string.Empty, title, gridInfo, propertyNameForValue, propertyNameForDisplay, propertyNameForBinding, isMultiSelect, null, readOnly, null, clientDependentFeature, null)); }
public static MvcHtmlString LookUpCr <TModel>(this HtmlHelper helper, string id, string title, GridInfo gridInfo, string propertyNameForValue, string propertyNameForDisplay, string propertyNameForBinding, Dictionary <string, object> lookupTextBoxHtmlAttributes, ClientDependentFeature clientDependentFeature) where TModel : IViewModel, new() { return(LookUpCr <TModel>(helper, id, string.Empty, title, gridInfo, propertyNameForValue, propertyNameForDisplay, propertyNameForBinding, null, false, lookupTextBoxHtmlAttributes, clientDependentFeature, null)); }