- Kentico EMS & Xperience
How to add a column to UniGrid in Kentico admin
In this post I will show you the way how to add a column to a UniGrid table in Kentico admin on an example of Product coupons.
Sometimes Kentico doesn't show all needed UniGrids columns in the administration. A good example could be the Product coupons application which doesn't display coupon codes. Let me show you how to add the column Coupon code to the UniGrid that lists coupons.
Find the aspx file that defines the UniGrid
We need to get to know what exactly represents the UniGrid to be able to modify it:
- Go to the Modules application > E-commerce.
- Switch to the User Interface tab and choose Product coupon in the tree.
- In the General tab there is the Target URL field which contains location of the file that defines the UniGrid. In our case it is ~/CMSModules/Ecommerce/Pages/Tools/DiscountCoupons/DiscountCoupon_List.aspx.
Modify the file
We have to tell the UniGrid definition that we need to load the DiscountCouponCode value in data source and add code that represents the column:
- Open the file in Visual Studio or any other code editor.
- Add DiscountCouponCode to the Columns attibute of the cms:UniGrid tag.
- Add the following code inside the GridColumns tag:
Add localization string
Value of the Caption attribute in the code above $com.discount.couponcode$ represents a localization string that needs to be translated:
- In Kentico admin go to the Localization application and create a new string.
- Paste the value in the Key field without the $ characters, add your translation as well.
That's it. Enjoy!