Can I pernamently override some settings in JqGridHelper?

May 22, 2014 at 1:49 AM
I have been using your great pack on my site and it has my life so much easier but I have found my self setting the some of the exact same properties for every grid I make. Is there some way I can change the default values for certain properties in the JqGridHelper?
Coordinator
May 22, 2014 at 10:13 PM
There is current;y no ready to use mechanism, but you can use inheritance. Just deliver your own JqGridOptions and use proper JqGridHelper constructor.
Marked as answer by Eagle_f90 on 6/2/2014 at 7:17 PM
Jun 4, 2014 at 12:04 AM
This is probably a really stupid question but I am just a beginner with ASP.Net. I tried to create my own Helper by right clicking on the JqGridHelper in VS and choosing "Go to definition" I then just copied and pasted that whole file into a new file and updated the properties I wanted to change. When I build I now get the error "must declare a body because it is not marked abstract, extern, or partial" for ach public member copied over. I am not sure why I am getting this error. I know it is probably really stupid but if you could help out that would be really appreciated.

This is what I ended up creating.
using Lib.Web.Mvc.JQuery.JqGrid;
using System.Collections.Generic;
using System.Web.Mvc;
using System;

namespace FFInfo.Core
{
 
    public class JqGridHelper<TModel> : IJqGridHelper
    {
        public JqGridHelper(JqGridOptions<TModel> options, object subgridHelper = null);

        public JqGridHelper(string id = "Grid",string afterInsertRow = null,string afterEditCell = null,string afterRestoreCell = null,string afterSaveCell = null,string afterSubmitCell = null,string altClass = "ui-priority-secondary",bool altRows = false,bool autoEncode = false,bool autoWidth = true,string beforeRequest = null,string beforeSelectRow = null,string beforeEditCell = null,string beforeSaveCell = null,string beforeSubmitCell = null,string caption = null,int cellLayout = 5,bool cellEditingEnabled = false,JqGridCellEditingSubmitModes cellEditingSubmitMode = JqGridCellEditingSubmitModes.Remote,string cellEditingUrl = null,string dataString = null,JqGridDataTypes dataType = JqGridDataTypes.Json,bool deepEmpty = false,JqGridLanguageDirections direction = JqGridLanguageDirections.Ltr,JqGridDynamicScrollingModes dynamicScrollingMode = JqGridDynamicScrollingModes.Disabled,int dynamicScrollingTimeout = 200,string editingUrl = null,string emptyRecords = "No resultes found.",bool expandColumnClick = true,string expandColumn = null,int? height = null,string errorCell = null,string formatCell = null,bool footerEnabled = false,bool gridView = false,bool groupingEnabled = false,JqGridGroupingView groupingView = null,bool headerTitles = false,bool hidden = false,bool hiddenEnabled = true,bool ignoreCase = true,JqGridJsonReader jsonReader = null,string loadBeforeSend = null,string loadError = null,string loadComplete = null,bool loadOnce = true,JqGridMethodTypes methodType = JqGridMethodTypes.Get,JqGridMultiKeys? multiKey = null,bool multiBoxOnly = false,bool multiSelect = false,int multiSelectWidth = 20,bool multiSort = false,string gridComplete = null,string onCellSelect = null,string onDoubleClickRow = null,string onHeaderClick = null,string onInitGrid = null,string onPaging = null,string onRightClickRow = null,string onSelectAll = null,string onSelectCell = null,string onSelectRow = null,string onSortCol = null,bool pager = true,JqGridParametersNames parametersNames = null,object postData = null,string postDataScript = null,string resizeStart = null,string resizeStop = null,string rowAttributes = null,List<int> rowsList = null,int rowsNumber = 20,bool rowsNumbers = false,int rowsNumbersWidth = 25,bool shrinkToFit = true,int scrollOffset = 18,string serializeCellData = null,string serializeGridData = null,string serializeSubGridData = null,bool sortable = false,string sortingName = "",JqGridSortingOrders sortingOrder = JqGridSortingOrders.Asc,bool subgridEnabled = false,JqGridSubgridModel subgridModel = null,object subgridHelper = null,string subgridUrl = null,int subgridColumnWidth = 20,string subGridBeforeExpand = null,string subGridRowColapsed = null,string subGridRowExpanded = null,bool topPager = false,bool treeGridEnabled = false,JqGridTreeGridModels treeGridModel = JqGridTreeGridModels.Nested,string url = null,bool userDataOnFooter = false,bool viewRecords = true,int? width = null);

        public string FilterGridId { get; }

        public string Id { get; }

        public string PagerId { get; }

        public JqGridHelper<TModel> AddActionsColumn(string name, int position = 0, int width = 60, bool editButton = true, bool deleteButton = true, bool useFormEditing = false, JqGridInlineNavigatorActionOptions inlineEditingOptions = null, JqGridNavigatorEditActionOptions formEditingOptions = null, JqGridNavigatorDeleteActionOptions deleteOptions = null);

        public JqGridHelper<TModel> AddNavigatorButton(JqGridNavigatorButtonOptions options);

        public JqGridHelper<TModel> AddNavigatorButton(string caption = "NewButton", string icon = "ui-icon-newwin", string onClick = null, JqGridNavigatorButtonPositions position = JqGridNavigatorButtonPositions.Last, string toolTip = "", string cursor = "pointer", bool cloneToTop = false);

        public JqGridHelper<TModel> AddNavigatorSeparator(JqGridNavigatorSeparatorOptions options);

        public JqGridHelper<TModel> AddNavigatorSeparator(string @class = "ui-separator", string content = "", bool cloneToTop = false);

        public JqGridHelper<TModel> FilterGrid(List<JqGridFilterGridRowModel> model = null, JqGridFilterGridOptions options = null);

        public JqGridHelper<TModel> FilterToolbar(JqGridFilterToolbarOptions options = null);

        public MvcHtmlString GetFilterGridHtml();

        public MvcHtmlString GetHtml();

        public MvcHtmlString GetJavaScript();

        public MvcHtmlString GetPagerHtml();

        public MvcHtmlString GetTableHtml();

        public JqGridHelper<TModel> InlineNavigator(JqGridInlineNavigatorOptions options);

        public JqGridHelper<TModel> Navigator(JqGridNavigatorOptions options, JqGridNavigatorEditActionOptions editActionOptions = null, JqGridNavigatorEditActionOptions addActionOptions = null, JqGridNavigatorDeleteActionOptions deleteActionOptions = null, JqGridNavigatorSearchActionOptions searchActionOptions = null, JqGridNavigatorViewActionOptions viewActionOptions = null);

        public JqGridHelper<TModel> SetFooterData(IDictionary<string, object> data, bool useFormatters = true);

        public JqGridHelper<TModel> SetFooterData(object data, bool useFormatters = true);

        public JqGridHelper<TModel> SetFrozenColumns();

        public JqGridHelper<TModel> SetGroupHeaders(IEnumerable<JqGridGroupHeader> groupHeaders, bool useColSpanStyle = false);
    }
}
Coordinator
Jun 13, 2014 at 3:21 PM
Why would you want to copy whole thing? Just simply deliver from it, something like this:
namespace FFInfo.Core
{
 
    public class MyJqGridHelper<TModel>: JqGridHelper<TModel>
    {
        // Override what you need here
        ...
    }
}
Jun 24, 2014 at 1:50 AM
TPeczek wrote:
Why would you want to copy whole thing? Just simply deliver from it, something like this:
namespace FFInfo.Core
{
 
    public class MyJqGridHelper<TModel>: JqGridHelper<TModel>
    {
        // Override what you need here
        ...
    }
}
Why? Because I suck at C# and ASP.Net. I will look into derived classes and work from there. Thanks.