Nipun Ambastha
Nipun Ambastha

Reputation: 2573

Custom table in Uniselector in Kentico

I have been using Kentico without issue for a while until today, here is my issue

I want to use Custom table in uniselector.

How I came into the issue was, I need to use Custom Form Controls, like in SiteManager->Users Advanced filter. We have Add Roles which opens a popup and it shows list of all roles.

This webpart uses Uniselector

<cms:CMSUpdatePanel ID="pnlUpdate" runat="server">
    <ContentTemplate>
        <cms:UniSelector ObjectType="cms.role" SelectionMode="MultipleTextBox"
            OrderBy="RoleDisplayName" ResourcePrefix="roleselect" runat="server"
            ID="usRoles" ShortID="s" AllowEditTextBox="true" AddGlobalObjectSuffix="true" />
    </ContentTemplate>
</cms:CMSUpdatePanel>  

Now if I use

ObjectType="cms.role" 

it works fine because it is system table

now if I use

ObjectType="customtable.country"

This will not work

Any help is appreciated. Thanks in advance.

Upvotes: 3

Views: 3173

Answers (3)

rocky
rocky

Reputation: 7696

Since version 7 you can use:

ObjectType="customtableitem.namespace.customtable"

it would be

ObjectType="customtableitem.customtable.SampleTable"

for Sample custom table (from Corporate sample site).

Feel free to contact me if you have any other questions.

Upvotes: 10

Prashant Mehta
Prashant Mehta

Reputation: 482

we have changed uniselector.ascx, keeping in mind that kentico can overwrite it when it gets updated use this CMSAdminControls

I use this approach and get success Created new pages as

  1. CustomUniSelector.ascx
  2. CustomSelectionDialog.ascx

Change method Loadobject as give url ~/CMSAdminControls/Mycustomcontrol/CustomSelectionDialog.aspx

than change LoadControls() method in CustomSelectionDialog.ascx.cs

CMSObjectHelper.GetObject() method not get data from custom table so added new method for fetching data from custom table

Upvotes: 0

Filip Ligac
Filip Ligac

Reputation: 19

Unfortunately, UniSelector requires Kentico object types by design and it does not work for custom tables.

However, there are basically three possible workarounds:

  1. You can develop custom form control instead of using UniSelector -> Developer's Guide - Developing form controls
  2. Use built-in Drop-down list control
  3. Modify UniSelector form control - you will load your DataSet in LoadObjects() method in file ~\CMSAdminControls\UI\UniSelector\UniSelector.ascx.cs

Upvotes: 1

Related Questions