HI
I have a entity object graph to be used as a Datasource to the UltraGrid.
for example
Company has collection of Branches
Table Company
int ComanyId
String CompanyCode
Address CompanyAddress
IList Branch
Table Address
int AddressId
String Location
String City
Table Branch
int BranchId
String BranchName
Address BranchAddress
i have to show in the grid with columns from Company and Branches as hirarchial
so Top Band should have
CompanyId ComanyCode Location (Address) City (Address)
and child Band should have
BranchId BranchName
i have around > 3000 records of IList<Company>....since, the default behaviour of ultragrid shows all public properties as columns and any IList as sub bands. i wont reach my requirements
ofcourse, i can achieve this by converting the list to DataTable......but, this requires conversion and while saving edited data have to change back as Object again...this is causing performance issue, for us object graph is huge (using Nhibernate)
can anyone help?
Thanks
I'm afraid I don't understand what you are asking. If you bind the grid to a list of Company objects as you have defined them here, then the grid will display it as a hierarchy, exactly as you appear to want. So... what exactly is the issue?
Everything you are describing here is the default behavior of the grid.
HI Mike,
Thanks for the Reply,
i have Object with Properties
Company
Address
Branch
---------------------------------------------------------
The grid Columns to be shown are
CompanyCode, Location, City in Band-0
BranchName, Location, City in Band-1
if i assign Company as datasource to grid , it shows columns companyid, companycode, address as object(ToString)...etc which is defaultbehaviuor.
but i need something like,
Customer.CustomerCode, Customer.Address.Location and Customer.Address.City in Band-0 ...etc
how can i achive this?
Hi Mike,
Thanks for the tip...i think this could solve my issue in some extent
Oh, okay. There's no way to do that automatically. The grid will display the data structure you bind it to, and your structure here has a single field for the address.
But you could handle this with just a few lines of code.
In the InitializeLayout event of the grid, you can set the Hidden property on the CompanyId and CompanyAddress columns. Then add a couple of unbound columns to the band called Location and City.
Use the InitializeRow event of the grid to get the Address object from the CompanyAddress field and populate the Location and City cells with the appropriate values.
If these cells need to be updateable, then you can reverse this process in the BeforeRowUpdate event - taking the values of the unbound columns and updating the address object in the hidden column.