Site structure
Version 5.x > Site structure > how to define a new object type View modes: 
User avatar
Member
Member
mj-y - 12/23/2012 12:27:49 AM
   
how to define a new object type
Hi
I want to create a drop down list that read data from a custom table ... (like status selector in ecommerce module ) ... but I don't know how should I define an object type like "ecommerce.orderstatus" that is used in code below ...
<cms:UniSelector ID="uniSelector" runat="server" DisplayNameFormat="{%StatusDisplayName%}"
ObjectType="ecommerce.orderstatus" ResourcePrefix="orderstatusselector" SelectionMode="SingleDropDownList"
AllowEmpty="false" />

this code is in this page (\CMSModules\Ecommerce\FormControls\OrderStatusSelector.ascx)

thx in advance for ur helps...

User avatar
Kentico Developer
Kentico Developer
kentico_ivanat - 12/23/2012 7:23:30 AM
   
RE:how to define a new object type
Hi,

the object type can be defined in the full source code.

In case you would like to create a list without need to define object type you can use unigrid instead.
It has a DataSource property so you can bind it with data.

Here is an example:
<%@ Register Src="~/CMSAdminControls/UI/UniGrid/UniGrid.ascx" TagName="UniGrid" TagPrefix="cms" %>
<%@ Register Namespace="CMS.UIControls.UniGridConfig" TagPrefix="ug" Assembly="CMS.UIControls" %>

<cms:UniGrid ID="ugSteps" runat="server" ShowObjectMenu="false" PageSize="All">
<GridActions>
<ug:Action Name="edit" CommandArgument="Name" Caption="$General.Edit$" Icon="Edit.png" />
<ug:Action Name="delete" CommandArgument="Name" Caption="$General.Delete$"
Icon="Delete.png" Confirmation="$CheckoutProcess.ConfirmDefaultProcess$" />
<ug:Action Name="up" CommandArgument="Name" Caption="$CheckoutProcess.btnMoveUpToolTip$"
Icon="Up.png" />
<ug:Action Name="down" CommandArgument="Name" Caption="$CheckoutProcess.btnMoveDownToolTip$"
Icon="Down.png" />
</GridActions>
<GridColumns>
<ug:Column Source="##All##" Caption="$CheckoutProcess.Order$" Wrap="false" ExternalSourceName="StepOrder">
</ug:Column>
<ug:Column Source="Caption" Caption="$CheckoutProcess.Caption$" Wrap="false">
</ug:Column>
<ug:Column Wrap="false" Width="100%" />
</GridColumns>
ugSteps.DataSource = ds;
ugSteps.DataBind();

More information about unigrid configuration you can find in unigrid configuration section.

For example option ShowSelection displays checkboxes next to each item.

Best regards,
Ivana Tomanickova

User avatar
Member
Member
mj-y - 12/23/2012 11:03:46 PM
   
RE:how to define a new object type
Hi
thx for your reply ..I have the full source and I want to use the object types in other parts too ... I will appriciate if you explain me how to define them.

User avatar
Member
Member
mj-y - 12/24/2012 5:49:27 AM
   
RE:how to define a new object type
add to previous post: I mean that I have the source of dlls ... and I want to write a new dll for myself ...
in some parts the object types are have sent to CMS.SettingsPrivider.dll functions ... and the code of this dll is not available for me ... so I can't understand the process .. I will apriciate if you explain how can I define a new Object Type ....

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 12/24/2012 8:16:08 AM
   
RE:how to define a new object type
Hi,

You won't be able to do this without the source code license. Ivana's post is the best way how to workaround this. However, if you are using custom table, have you tried using the class name of the custom table object (it should be the same as the cusotm table code name)?

Is you want to have a custom DLL, you need to add new project to the solution as it is usual for any other .Net project - in Visual Studio click File -> Add -> New project -> Class library. Then you need to add references to this new class and also vice versa, references to Kentico's DLLs.

Best regards,
Juraj Ondrus

User avatar
Member
Member
mj-y - 12/24/2012 11:02:35 PM
   
RE:how to define a new object type
Hi,
thx for your reply ... I have used the way u said to create a new dll ... and I have the source code License too ...
I have used the table name too ... there is a table named dbo.Ad_Status in my database and I used the code below for it:
<cms:UniSelector ID="uniSelector" runat="server" DisplayNameFormat="{%StatusName%}"
ObjectType="Ad.Status" ResourcePrefix="adstatusselector" SelectionMode="SingleDropDownList"
AllowEmpty="false" />

but it just shows this error in browser : [UniSelector]: Object type 'Ad.Status' not found.

and also if the name of tables is an objectType that refers to them ... why we have an object like "ecommerce.orderstatus" but we don't have a table named like this?
If there is something that yo can't say others who don't have the license ... I will be appriciate if you send me email ... mj.yazdani1988@gmail.com

User avatar
Kentico Support
Kentico Support
kentico_zdenekc - 12/25/2012 4:06:50 AM
   
RE:how to define a new object type
Hi,

This error appears when there are no data returned by private void LoadObjects method within the UniSelector code.

Table name doesn't match the object type, e.g. we use dot (.) in classnames, but DB tables use underscore in the name (after dbo.)
Each object type, defined as a record in the CMS_Class table, has it's ClassTableName property, where the DB table name is defined.

Do you have it configured like this in your Class definition (CMS_Class record for classname 'Ad.Status' mapped to Ad_Status DB table name)?

Regards,
Zdenek

User avatar
Member
Member
mj-y - 12/30/2012 2:17:02 AM
   
RE:how to define a new object type
Hi dear zdenekc
I checked the CMS_Class table ... my table name is automatically mapped there and it's ClassName is "AD.Status" ... so I used the code below:
<cms:UniSelector ID="uniSelector" runat="server" DisplayNameFormat="{%StatusName%}"
ObjectType="AD.Status" ResourcePrefix="selectall" SelectionMode="SingleDropDownList"
AllowEmpty="false" />

but I receive that error again :( ...

you said that this occurs when no data returned by private void LoadObjects method within the UniSelector code ... Are u sure that it's the only reason of this error?... I have some rows in my table ... how should I be sure that data is returned by that or not?!

User avatar
Member
Member
mj-y - 1/8/2013 6:47:48 AM
   
RE:how to define a new object type
heloooo ... Is there any one who answer my question .... I really need to define an ObjectType :(

User avatar
Kentico Support
Kentico Support
kentico_zdenekc - 1/11/2013 7:27:41 AM
   
RE:how to define a new object type
Hi,

Which version of Kentico CMS exactly are you using? We're in 5.x forum section, but I'd like to know exact version.

Basically, before version 6, the columns are not dynamically loaded, so an option is the way of defining columns manually and obtaining and binding a DataSource, as Ivana describes in her post. You cannot use ObjectType for the custom table.

Regards,
Zdenek

User avatar
Member
Member
mj-y - 1/14/2013 12:00:26 AM
   
RE:how to define a new object type
I use kentico 5.5R2 ... sorry I thought the full source is just the source of dlls ... ok I would use Ivana's code ....

User avatar
Member
Member
r.zareianfard-yahoo - 9/25/2013 9:08:44 AM
   
RE:how to define a new object type
I don't have full license but I think it's possible to define new object type without having full source in version 7, am I right?
If yes please help me,
I created a CityInfo class and a CityInfoProvider same as StateInfo and StateInfoProvider...
I added a record to cms_class table and created cms_city (the classname is cms.city)
but when I set the UIForm control's objecttype and click new it returns

I checked and applications calls CityInfo static constructor correctly and creates TYPEINFO object.
Should I do anything else to introduce this object type to system?

User avatar
Member
Member
r.zareianfard-yahoo - 9/25/2013 9:36:17 AM
   
RE:how to define a new object type
Sorry The error is not pasted :
it returns The object does not exist. It may have been deleted by someone else. when I load UIForm for inserting data

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 9/26/2013 12:30:58 AM
   
RE:how to define a new object type
Hello,

Duplicate content, answer will be posted in this thread.

Best regards,
Juraj Ondrus