When I used static Page tables in Nopcommerce, I found that the Topic table does not have sorting fields and category fields. As a result, if there are many Page files, the category cannot be distinguished. For this reason, I expanded the field a little, record the operation process here for future reference and share it with our friends!
// ================================================ ======================================================================/Add field // =================================================== ==================================================================== // /<summary> // display sequence // </summary> public int DisplayOrder {get; set ;}//< summary> /// category name /// </summary> public string CategoryName {get; set ;} // ================================================ ============================================2. Add two fields DisplayOrder and CategoryName to the TopicModel object in the management background.
// ================================================ ======================================================================/Add field // =================================================== ================================================ [NopResourceDisplayName ("Admin. contentManagement. topics. fields. displayOrder ")] public int DisplayOrder {get; set;} [NopResourceDisplayName (" Admin. contentManagement. topics. fields. categoryName ")] public string CategoryName {get; set ;} // ================================================ ============================================
3. Add the display names of DisplayOrder and CategoryName to the resource library.
Open website background
Admin. ContentManagement. Topics. Fields. DisplayOrder and Admin. ContentManagement. Topics. Fields. CategoryName. If they do not exist, add them.
Resource name: Admin. ContentManagement. Topics. Fields. DisplayOrderValue:Sort
Resource name: Admin. ContentManagement. Topics. Fields. CategoryNameValue: Category name
<Tr> <td class = "adminTitle"> @ Html. nopLabelFor (model => model. categoryName): </td> <td class = "adminData"> @ Html. editorFor (model => model. categoryName) @ Html. validationMessageFor (model => model. categoryName) </td> </tr> <td class = "adminTitle"> @ Html. nopLabelFor (model => model. displayOrder): </td> <td class = "adminData"> @ Html. editorFor (model => model. displayOrder) @ Html. validationMessageFor (model => model. displayOrder) </td> </tr>
4.2 modify List View
Open the "Nop. Admin" Project->Open the Views folder-> "Topic"-> "list. cshtml"
<Table class = "adminContent"> <tr> <td> @ (Html. telerik (). grid <TopicModel> (). name ("topics-grid "). columns (columns => {columns. bound (x => x. systemName); columns. bound (x => x. title); columns. bound (x => x. categoryName); columns. bound (x => x. displayOrder); columns. bound (x => x. isPasswordProtected ). template (@ ). clientTemplate (". gif '/> "). centered (). length (100); columns. bound (x => x. includeInSitemap ). template (@ ). clientTemplate (". gif '/> "). centered (). length (100); columns. bound (x => x. id ). width (50 ). centered (). template (x => Html. actionLink (T ("Admin. common. edit "). text, "Edit", new {id = x. id })). clientTemplate ("<a href = \" Edit/<# = Id #> \ ">" + T ("Admin. common. edit "). text + "</a> "). title (T ("Admin. common. edit "). text );}). dataBinding (dataBinding => dataBinding. ajax (). select ("List", "Topic ")). clientEvents (events => events. onDataBinding ("onDataBinding ")). enableCustomBinding (true) </td> </tr> </table>
5. Sort the List of topics in ascending order of DisplayOrder.
6. preview the effect
List page
Add and modify page
7. Summary
If Nop is such a powerful system, it is inevitable that some requirements will not be fully considered! I will share my changes with you. It's off duty. Tomorrow go on!