We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Datasource column to TableDescriptor column mapping

Thread ID:

Created:

Updated:

Platform:

Replies:

69027 Oct 10,2007 10:22 AM Oct 16,2007 10:37 AM Windows Forms 5
loading
Tags: Grouping
mitul
Asked On October 10, 2007 10:22 AM

Hi,

Is there a (quick and efficient) way I can find which column index in my visible column collection maps to a particular column in my datasource?

I am using a datatable as source, and would like to know which column on my grid maps to a column in my datatable. As the columns can be rearranged, I cannot hardcode this. Is there some mapping available somewhere?

Thanks,
Mitul

Administrator [Syncfusion]
Replied On October 12, 2007 05:38 AM

You can use VisibleColumns.IndexOf to locate a particular field in the grid.


int loc = gridGroupingControl1.TableDescriptor.VisibleColumns.IndexOf("columnName");



mitul
Replied On October 15, 2007 06:55 AM

Hi Clay,

Is this the most efficient way there is? I have tried this and the lookup seems quite CPU intensive. I'd be doing this operation up to 3 times a second...

Also, any update to my other thread regarding the customised filter bar example?

Thanks,
Mitul

>You can use VisibleColumns.IndexOf to locate a particular field in the grid.


int loc = gridGroupingControl1.TableDescriptor.VisibleColumns.IndexOf("columnName");



Administrator [Syncfusion]
Replied On October 15, 2007 09:25 AM

You could maintain your own hashtable/dictionary that would map names to visiblecolumn prosition. You could use the above method to initailly populate the original mapping object. Then listen to the TableDescriptor.VisibleCOlumnsChanged event to reset your mapping object as needed if you are allowing your user to move columns or hide/show columns.

But unless you have a large number of visible columns, I would not think VisibleColumns.IndexOf would be a big cpu load. (Now, the first time the method is accessed may be a big load, because the GridGroupingControl uses a lazy architecture when it comes to actually populating structures, postponing the work until they are actually needed. So, the first access may actually trigger things like sorts/groupings/data loading, etc. But, thereafter, it should essentially be a quick index lookup using IndexOf on a small collection). So, the real question might be what else are you doing 3 times a second?

mitul
Replied On October 15, 2007 11:09 AM

I am currently performing the following operation:

Grid.TableControl.RefreshRange(Grid.TableControl.ViewLayout.VisibleCellsRange);

But want to do something that refreshes less of the grid, so am trying:

.TableControl.RefreshRange(GridRangeInfo.Col(Grid.TableDescriptor.VisibleColumns.IndexOf("Price"));

I would be doing this for up to 8 columns (out of roughly 35).

I have to use this method of refreshing because we have disabled the built in update mechanism, as the event to update the grid was firing on *each* individual change of the underlying datatable, despite using BeginUpdate and EndUpdate. (I update every datarow and multiple columns in each row) - this was very CPU intensive.

Do you have any suggestions on how refreshing the grid can be made more efficient?

Thanks,
Mitul
>You could maintain your own hashtable/dictionary that would map names to visiblecolumn prosition. You could use the above method to initailly populate the original mapping object. Then listen to the TableDescriptor.VisibleCOlumnsChanged event to reset your mapping object as needed if you are allowing your user to move columns or hide/show columns.

But unless you have a large number of visible columns, I would not think VisibleColumns.IndexOf would be a big cpu load. (Now, the first time the method is accessed may be a big load, because the GridGroupingControl uses a lazy architecture when it comes to actually populating structures, postponing the work until they are actually needed. So, the first access may actually trigger things like sorts/groupings/data loading, etc. But, thereafter, it should essentially be a quick index lookup using IndexOf on a small collection). So, the real question might be what else are you doing 3 times a second?

Administrator [Syncfusion]
Replied On October 16, 2007 10:37 AM

Try code like this to see if it works quicker for you.

this.gridGroupingControl1.TableControl.UpdateWithDrawClippedGrid(gridGroupingControl1.TableControl.ClientRectangle);

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;