Esempio n. 1
0
        private static void ConfigureCrudButtons(Grid grid, GridMetamodel gridModel)
        {
            if (gridModel.DetailsLink.IsEnabled)
            {
                grid.AddColumn(new Column("DetailsLink")
                    .SetLabel(gridModel.DetailsLink.Text)
                    .SetWidth(70).SetFixedWidth(true)
                    .SetSortable(false)
                    .SetSearch(false)
                    .SetCustomFormatter("buildDetailsLink"));
            }

            if (gridModel.EditLink.IsEnabled)
            {
                grid.AddColumn(new Column("EditLink")
                    .SetLabel(gridModel.EditLink.Text)
                    .SetWidth(50).SetFixedWidth(true)
                    .SetSortable(false)
                    .SetSearch(false)
                    .SetCustomFormatter("buildEditLink"));
            }

            if (gridModel.DeleteLink.IsEnabled)
            {
                grid.AddColumn(new Column("DeleteLink")
                    .SetLabel(gridModel.DeleteLink.Text)
                    .SetWidth(50).SetFixedWidth(true)
                    .SetSortable(false)
                    .SetSearch(false)
                    .SetCustomFormatter("buildDeleteLink"));
            }
        }
Esempio n. 2
0
        public Grid Configure(GridMetamodel gridModel, string gridDataAction, string gridId)
        {
            var grid = this.html.Grid(gridId);
            ConfigureGrid(grid, gridModel, gridDataAction);
            this.ConfigureModelColumns(grid, gridModel);
            ConfigureCrudButtons(grid, gridModel);

            return grid;
        }
Esempio n. 3
0
        public static MvcHtmlString JqGrid(this HtmlHelper html, GridMetamodel gridModel, string gridDataAction)
        {
            var gridId = "mainGrid";

            var configurator = new JqGridConfigurator(html);
            var grid = configurator.Configure(gridModel, gridDataAction, gridId);

            var gridMarkup = JqGridConfigurationUpdater.FixGridConfiguration(
                grid.ToString(), gridId, UiTexts.GridButton_Clear, UiTexts.GridSearch_DropDown_All);
            return MvcHtmlString.Create(gridMarkup);
        }
Esempio n. 4
0
        public GridMetamodel <TGridModel> Build()
        {
            if (string.IsNullOrEmpty(this.getGridDataActionName))
            {
                throw new GridBuildingException("GridDataActionName must be provided. Call SetDataActionName before Build.");
            }
            if (this.columns == null)
            {
                throw new GridBuildingException("Grid without any columns could not be created. Call AddColumn at least one time before Build.");
            }

            var gridMetaModel = new GridMetamodel <TGridModel>(this.gridCaption, this.getGridDataActionName,
                                                               this.newItemLink, this.detailsLink, this.editLink, this.deleteLink, this.columns, this.defaultSortSettings);

            return(gridMetaModel);
        }
Esempio n. 5
0
 private static void ConfigureGrid(Grid grid, GridMetamodel gridModel, string gridDataAction)
 {
     grid
         // basic:
         .SetCaption(gridModel.Caption)
         .SetUrl(gridDataAction)
         .SetHideGrid(false)
         .SetAutoWidth(true)
         // pagination:
         .SetPager("pager")
         .SetTopPager(true)
         .SetRowList(new[] {
             10, 20, 50, 100
         })
         .SetViewRecords(true)
         // sorting and filtering:
         .SetShowAllSortIcons(true)
         .SetSearchToolbar(true)
         .SetSearchOnEnter(true)
         .SetSearchClearButton(true)
         // events:
         .OnGridComplete("gridComplete()")
         .OnLoadError("showGridError(xhr.responseText);");
 }
Esempio n. 6
0
        private void ConfigureModelColumns(Grid grid, GridMetamodel gridModel)
        {
            foreach (var metamodel in gridModel.Columns)
            {
                var metamodelType = metamodel.GetType();
                var configurator = this.GetConfigurator(metamodelType);
                var column = configurator.Render(metamodel);

                grid.AddColumn(column);
            }
        }