Search code examples
kentico

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


Solution

  • 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.