Cangoo
Cangoo

Reputation: 91

Extending columns of the admin user grid Kentico 10

I use Kentico 10.
I try to show new custom columns in the user grid. (please see picture below)

What's the best way to do it,
so that it still works after a Kentico update?

enter image description here

Upvotes: 1

Views: 466

Answers (2)

Brenden Kehren
Brenden Kehren

Reputation: 6117

Best thing to do is create your own XML file based on this file:

/CMSModules/Membership/Pages/Users/User_List.xml

and add your field like so:

<column source="##ALL##" externalsourcename="#transform:cms.user:PriceListAllowed#isnullyesno" caption="Price List Allowed" allowsorting="true"/>

Second, you'll need to create a query which gets the fields you're expecting. Look in the current XML file and you'll see the object it's referencing is an object which is created in code and you have no control over it:

<objecttype name="cms.userlist" />

The cms.userlist is essentially calling the View_CMS_User view. You have a few options:

  • Modify the existing view (not recommended)
  • Create your own query in the Membership module on the User class which will join the cms_user table to the cms_usersettings table and selects " * " for the list of columns and it will automatically include your new columns.

Then go back to the XML file you created and remove the objecttype node and add a <query> element like so:

<query name="cms.user.yourcustomqueryname" />

This should get you what you're looking for. The only thing which may be overwritten in an upgrade would be the path to the Users XML file in the User module. So that should be pretty easy to update that path if it is overwritten.

Upvotes: 2

Peter Mogilnitski
Peter Mogilnitski

Reputation: 998

You have to edit unigrid definition file located at ~/CMSModules/Membership/Pages/Users/User_List.xml

I've tried with <column source="##ALL##" externalsourcename="#transform:cms.user:PriceListAllowed#isnullyesno" caption="PriceListAllowed" allowsorting="true"/> and it does not seem to work. Your probably need to add columns to the grid query, this means you have to create Unigrid Extender (here is an example). Take a look also at creating extenders.

P.S. You might as well put your column in usersettings and use it as reference tabl. here is an example

Upvotes: 0

Related Questions