API Questions on Kentico API.
Version 5.x > API > Setting BizForm column externalsourcename with API? View modes: 
User avatar
Member
Member
markcoatsworth - 12/10/2012 9:46:32 AM
   
Setting BizForm column externalsourcename with API?
Hi there,

I'm working on a BizForm where one of the columns contains a foreign key.

When I log into CMSDesk to view the data in this form, it displays the foreign key ID values in this column. But I want it to display the actual data which this foreign key points to.

Normally, this would be easy. I would just open the unigrid.xml definition file, set the <column externalsourcename=""...> attribute, and then use the gridData_OnExternalDataBound() function to query the other table and retrieve the data I want.

However, in this case I'm working on the /CMSModules/Bizforms/Tools/BizForm_Edit_Data.ascx.cs file. All the unigrid columns/data is populated with the API. The BizForm_Edit_Data.xml file does not contain any column definitions.

Is there a way I can set the externalsourcename attribute with the API? I've looked everywhere and can't find an answer. Please let me know,

Mark

User avatar
Kentico Support
Kentico Support
kentico_zdenekc - 12/20/2012 2:14:53 PM
   
RE:Setting BizForm column externalsourcename with API?
Hi,

In the ~\CMSModules\BizForms\Tools\BizFormEditData.ascx.cs, the columns are loaded dynamically in the gridData_OnLoadColumns(). You have probably found that.
Here it should be possible to perform a lookup in the other table.
The current version (7.0) of this control (in \CMSModules\BizForms\Controls\BizFormEditData.ascx.cs) uses Linq, maybe it could be helpful too.

Another way could be a completely custom BizForm data listing page.
Should you need any particular details, please feel free to ask.

Regards,
Zdenek

User avatar
Member
Member
markcoatsworth - 12/24/2012 10:40:33 AM
   
RE:Setting BizForm column externalsourcename with API?
Hi Zdenek,

Thanks for your help! Unfortunately these solutions don't really work.

I'm working within the gridData_OnLoadColumns() method as you suggested. At the very end of this method, the system adds the columns to the grid using the following line of code:

gridData.AddColumn(fieldCaption, column, 0, true);

The problem here is that I *also* want to add an externalsourcename value. However it's not possible with this method. And from what I can tell, there is no way to set externalsourcename values with the API.

Please let me know if there is some other way. Keep in mind this project is running on Kentico 5.5 R2 so we can't use newer features.

Thanks!

Mark

User avatar
Kentico Support
Kentico Support
kentico_zdenekc - 1/9/2013 11:16:06 AM
   
RE:Setting BizForm column externalsourcename with API?
Hi Mark,

The options in earlier versions are limited and this scenario probably won't be available. However the LINQ constructions should be available back in 5.5R2 normally...

I'm sorry I couldn't find any particular working solution yet.

Probably an easiest way would be to create a custom control/page with a custom datasource using a query that would join both tables, so the grid can display all the records directly.

Have you already found any solution?

Regards,
Zdenek


User avatar
Member
Member
markcoatsworth - 1/22/2013 11:40:04 AM
   
RE:Setting BizForm column externalsourcename with API?
Hi Zdenek,

Unfortunately I was not able to find a solution for this in Kentico 5.5 R2. I don't think it's possible.

Instead I used a simple workaround. First I added a new text field to the bizform. Then I modified the ~\CMSModules\BizForms\Tools\BizFormEditData.ascx.cs file, and I changed the gridData_OnDataReload() method to lookup the value on my foreign key ID and display this in my new text field. It's not a perfect solution, but it works!

Mark

User avatar
Kentico Support
Kentico Support
kentico_zdenekc - 2/1/2013 10:59:00 AM
   
RE:Setting BizForm column externalsourcename with API?
Hi Mark,

Okay, glad to hear that you've found this workaround!
Maybe it would be good to modify a cloned control (and just point the UI to it), in order to keep the changes separately from default code for case of upgrading... but maybe it's not a priority now...

Regards,
Zdenek