API
Version 7.x > API > Get properties/columns of a CustomTable View modes: 
User avatar
Kentico Legend
Kentico Legend
Brenden Kehren - 1/15/2013 2:57:10 PM
   
Get properties/columns of a CustomTable
I'd like to loop through all the properties a Custom Table has and I've found they aren't available in DataClassInfo.Properties but I have found them in the DataClassInfo.ClassXMLSchema. Is there a method to get these properties out so I can loop through them or will I need to parse the XML out?

User avatar
Kentico Legend
Kentico Legend
Brenden Kehren - 1/17/2013 12:56:23 PM
   
RE:Get properties/columns of a CustomTable
Well I was able to use some Linq to XML and got what I needed:

DataClassInfo LocationRecord = DataClassInfoProvider.GetDataClass("MyClass.Location");

if (LocationRecord != null)
{
List<string> locationProperties = new List<string>();

var doc = XDocument.Parse(LocationRecord.ClassFormDefinition); // or XDocument.Load()
var elements = from e in doc.Descendants("field")
where e.Attribute("columntype").Value == "boolean" &&
e.Attribute("visible").Value == "true"
select e;

foreach (XElement x in elements)
{
locationProperties.Add(ValidationHelper.GetString(x.Attribute("column").Value, ""));
}
}
Hope this helps others or if you have a method, would love that too!

User avatar
Kentico Customer Success
Kentico Customer Success
kentico_martind2 - 1/18/2013 2:05:17 AM
   
RE:Get properties/columns of a CustomTable
Hi,

Thanks for the additional post, really nice job! I hope it will help others too.

Best regards,
Martin Danko