Bug reports Found a bug? Post it here please.
Version 7.x > Bug reports > Custom table datagrid selection View modes: 
User avatar
Kentico Legend
Kentico Legend
Brenden Kehren - 6/12/2013 3:01:42 PM
   
Custom table datagrid selection
I'm attempting to "select" an item within the custom table datagrid web part and dynamically populate the Detail page path using a macro. It fails to work properly when I have a custom table object I've created based on a table that was manually created via query or SSMS.

My steps were:
- I created a new table in SSMS called MyNotifications.
- I added 3 fields: NotificationID (primary key, auto generated INT), NotificationText (nvarchar(max)), PublishTo, PublishFrom (both dates).
- I create the table within the Site Manager>Development>Custom Tables and enter my custom table display name as well as selecting the existing, MyNotifications table.
- I selected all the checkboxes to include the other default fields (ItemGUID, ItemCreatedBy, etc.).
- All works well when creating the table and displaying the data in other web parts.

Now I add the Custom table datagrid web part to a page. I selected the MyNotifications custom table and enter the Order by property. I selected the Displayed columns, which included NotificationID, NotificationText. I checked that NotificationID should be a link (expecting that to be the "selected item" column with the primary key for that row). Then I make my dynamic URL with a macro, I used {% CurrentUrl + NotificationID %} and the NotificationID value is always returned as 0.

When I looked in the custom table datagrid webpart code it is hard coded to look for the "ItemID" field vs. the custom table's primary key, which could be dynamically populated with the 2 simple lines of code
IDataClass idc = DataClassFactory.NewDataClass(CustomTable);
int itemId = ValidationHelper.GetInteger(DataHelper.GetDataRowViewValue((DataRowView)e.Item.DataItem, idc.IDColumn), 0);
Second part which isn't so much of a bug but more of a hassle is the URL parameter. The URL parameter is hard coded to append with the key of "id". This should be an additional property the user can specify, with a default of "id" if not populated. Then I can hook it up to other web parts and use the URL parameter key of my choice.

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 6/20/2013 6:14:07 AM
   
RE:Custom table datagrid selection
Hi,

I got little bit lost by two things:

1.
I checked that NotificationID should be a link (expecting that to be the "selected item" column with the primary key for that row).
- which property of the datagrid you mean exactly? I am not sure if I am reproducing the issue correctly - so far it is working for me and I do not know what exactly you mean.

2.
Then I make my dynamic URL with a macro, I used {% CurrentUrl + NotificationID %} and the NotificationID value is always returned as 0.
- basically the same as #1 - do you mean the Detail page path? Have you tried using the macro like:

GlobalObjects.CustomTables["customtable.MyNotifications"]...


I do not think that custom table column data are part of default context macros.


Best regards,
Juraj Ondrus

User avatar
Kentico Legend
Kentico Legend
Brenden Kehren - 6/20/2013 7:31:59 AM
   
RE:Custom table datagrid selection
Sorry to confuse you on this. Ideally what I want to happen is dynamically create a URL that goes to another page I've created (or an alias of the current page with another web part to display the selected item).

In regards to #1, I've attached an image below. It's a poor example because I'm using a text field but imagine the NotificationText field was the custom tables primary key.User image
In regards to #2, Yes, the detail page path or an alias of the current page with a "selected item ID". How do I get the value from the GlobalObjects.CustomTables macro?

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 6/21/2013 2:04:02 AM
   
RE:Custom table datagrid selection
Thank you, got it!

Doing some research about the macro for getting custom table data. In v7 there is no method implemented for this - I am sorry for the inconvenience but you will have to create a custom macro.

In version 8 is this already ensured.

Best regards,
Juraj Ondrus