Exemplo n.º 1
0
        public static IHtmlString AdvancedSortFor(this HtmlHelper html, string gridName, object attributes = null, List <string> excludedColumn = null)
        {
            if (string.IsNullOrEmpty(gridName))
            {
                new MvcHtmlString(AppConstant.ErrorMissingGridName);
            }

            var model = new GridComponentConfigModel
            {
                GridName                = gridName,
                ExcludedColumn          = excludedColumn ?? new List <string>(),
                UseDefaultSortIconStyle = false,
                PreventAutoInitialize   = false,
                LocalStorageKey         = string.Empty
            };

            // bind attributes
            if (attributes != null)
            {
                model.ButtonOpenSortStyle     = Convert.ToString(attributes.GetType()?.GetProperty("ButtonOpenSortStyle")?.GetValue(attributes));
                model.ButtonClearSortStyle    = Convert.ToString(attributes.GetType()?.GetProperty("ButtonClearSortStyle")?.GetValue(attributes));
                model.UseDefaultSortIconStyle = Convert.ToBoolean(attributes.GetType()?.GetProperty("UseDefaultSortIconStyle")?.GetValue(attributes));
                model.PreventAutoInitialize   = Convert.ToBoolean(attributes.GetType()?.GetProperty("PreventAutoInitialize")?.GetValue(attributes));
                model.LocalStorageKey         = Convert.ToString(attributes.GetType()?.GetProperty("LocalStorageKey")?.GetValue(attributes));
            }

            return(html.Partial(AppConstant.ViewAdvancedSortToolStrip, model));
        }
Exemplo n.º 2
0
        public static IHtmlString AdvancedSortSharedResource(this HtmlHelper html, object attributes = null)
        {
            // assing a flag, so we can use this to avoid printing common resources more than once
            // this is needed to support sort component in mutiple grids in the same page
            SetFlagToHttpContext(AppConstant.AdvancedSortSharedResourceKey);

            var model = new GridComponentConfigModel
            {
                UseDefaultSortIconStyle = false,
                GridName = string.Empty
            };

            // bind attributes
            if (attributes != null)
            {
                model.UseDefaultSortIconStyle = Convert.ToBoolean(attributes.GetType()?.GetProperty("UseDefaultSortIconStyle")?.GetValue(attributes));
                model.GridName = Convert.ToString(attributes.GetType()?.GetProperty("GridName")?.GetValue(attributes));
            }

            return(html.Partial(AppConstant.ViewAdvancedSortSharedResource, model));
        }