05. NopCommerce adds sorting and category fields to the Topic table

Source: Internet
Author: User
Tags nopcommerce

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!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.