2014-09-10 26 views
0

我使用TPeczek的Lb.Web.Mvc插件,它一直工作的很棒,我注意到在我所有的网格中要重写默认值,所以我想永久更改这些设置,以免我总是将它们输出。据TPeczek做到这一点的唯一方法是从Lib.Web.Mvc插件中的JqGridHelper继承来覆盖属性一直抛出错误

deliver your own JqGridOptions and use proper JqGridHelper

,所以我做的第一件事就是看看股票JqGridHelper类和复制/粘贴到我的新类MyJqGridHelper但失败,错误

must declare a body because it is not marked abstract, extern, or partial

这里是我使用了错误的代码:

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); 
} 

然后我试图刚刚从基地JqGridHelper继承,只是重写一次公关operty我想改变,但这给了我必须声明返回类型的错误,我不知道什么是因为原始的JqGridHelper不返回类型。

public class MyJqGridHelper<TModel>: JqGridHelper<TModel> 
{ 
    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); 
} 

我试图将其更改为TModel返回类型,但是这使我回申报身体的错误,我第一次得到。在这一点上,我完全失去了我应该能够从股票类继承的能力,以便能够使用我自己的股票。

回答

1

实际上公共JqGridHelper返回的东西,但你不能看到在那里实现的代码。但如果您想查看JqGridHelper https://github.com/tpeczek/Lib.Web.Mvc/blob/master/Lib.Web.Mvc/JQuery/JqGrid/JqGridHelper.cs的完整源代码,请点击此链接。另外如果你有一个像resharper这样的工具,你可以反编译插件,并可以看到完整的源代码。 您可以创建自定义构造函数来调用jqgridhelper类构造函数并添加自定义参数。例如:

public class MyJqGridHelper<TModel>: JqGridHelper<TModel> 
{ 
    public MyJqGridHelper(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) 
    : base (id,afterInsertRow,afterEditCell,afterRestoreCell,afterSaveCell,afterSubmitCell,altClass,altRows ,autoEncode,autoWidth,beforeRequest,beforeSelectRow,beforeEditCell,beforeSaveCell,beforeSubmitCell, caption, cellLayout, cellEditingEnabled, cellEditingSubmitMode,cellEditingUrl,dataString,dataType,deepEmpty,direction, dynamicScrollingMode, dynamicScrollingTimeout, editingUrl, emptyRecords, expandColumnClick, expandColumn ,height, errorCell, formatCell, footerEnabled, gridView, groupingEnabled , groupingView, headerTitles , hidden , hiddenEnabled , ignoreCase , jsonReader , loadBeforeSend , loadError , loadComplete , loadOnce , methodType , multiKey , multiBoxOnly, multiSelect , multiSelectWidth , multiSort , gridComplete , onCellSelect , onDoubleClickRow , onHeaderClick , onInitGrid , onPaging , onRightClickRow , onSelectAll , onSelectCell , onSelectRow , onSortCol , pager , parametersNames , postData , postDataScript , resizeStart , resizeStop , rowAttributes , rowsList , rowsNumber , rowsNumbers , rowsNumbersWidth , shrinkToFit , scrollOffset , serializeCellData , serializeGridData , serializeSubGridData , sortable , sortingName , sortingOrder , subgridEnabled , subgridModel , subgridHelper , subgridUrl , subgridColumnWidth , subGridBeforeExpand , subGridRowColapsed , subGridRowExpanded , topPager , treeGridEnabled , treeGridModel , url , userDataOnFooter , viewRecords , width) 
    { 
     //other stuff here, if you want to do something different after calling base constructor 
    } 
} 
+0

使用构造函数已删除错误和页面构建没有错误。我现在无法测试,直到完成ViewModel并填充一些测试数据。希望今晚能够做到这一点,并会更新结果。 – Matthew 2014-09-10 18:17:27

+0

那么,它工作吗? – 2014-09-11 03:35:28

+0

我只是能够对此做一个完整的测试,它正在工作。谢谢。 – Matthew 2014-09-12 01:36:42