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.

Filtering

Thread ID:

Created:

Updated:

Platform:

Replies:

67554 Aug 23,2007 12:29 AM Sep 10,2007 09:01 PM Windows Forms 8
loading
Tags: GridControl
Kent Boogaart
Asked On August 23, 2007 12:29 AM

Hi,

When filtering is applied, how can I correlate the ranges reported by GetSelectedRanges() back to my data?

Say I have three items in my data source: 'one', 'two', 'three'. Suppose the user uses the filter bar to filter out all but 'three'. If they select 'three' it is reported as a range of [1,1]. But what I really want is [3,3] so I can correlate to the actual data they've selected.

What facility is provided to translate this range to the equivalent range assuming no filtering?

Thanks

Sarathi D [Syncfusion]
Replied On August 24, 2007 08:42 PM

Hi ,

This is a default behavior of the filtering functionality in our grid. If you want to keep the index of the selected ranges in a grid then you need to follow the below steps to resolve this.

1) To disable default functionality of the filter bar in a grid.
2) Add an extra row header for a grid using Model.Rows.HeaderCount property.
3) Change the celltype of the extra header cell to Combox celltype and set its DataSource,DisplayMember and ValueMember property using the QueryCellInfo event.
4) Hide the non matching rows of the grid depending on the SelectedValue of the Extra header combox cell in CurrentCellCloseDropDown event of the grid using the SetRange method.

Please try this and let us know if you have any other questions regarding this issue. We will be glad to assist you.

Best regards,
Sarathi

Kent Boogaart
Replied On August 26, 2007 08:34 PM

I'm confused. If there is no way to correlate selected ranges back to the data source, how is filtering even used in a real-world app?

All I want to do is something like:

_grid.DataSource = customers;

//later on
List selectedCustomers = new ...;

foreach (GridRangeInfo range in _grid.Selections)
{
//how do I get the Customer here?
selectedCustomers.Add(???);
}

Thanks

Sarathi D [Syncfusion]
Replied On August 28, 2007 09:30 PM

Hi,

We currently looking into this issue. I will update the status of the issue within one business day.

Sorry for the inconvenience.

Regards,
Sarathi

Kent Boogaart
Replied On August 28, 2007 10:08 PM

Guess I'll answer my own question then for others struggling with the same problem.

Firstly, you might think you could use:

_grid.Binder.RowIndexToListManagerPosition(index)

to translate the index to an index in the underlying data source. Indeed, that is exactly what this method is supposed to do. But it doesn't. No idea why.

To work around this, I access the DataView directly:

DataTable dataTable = _grid.DataSource as DataTable;
//i is just an index reported by a range from GetSelectedRanges()
int translatedIndex = _grid.Binder.RowIndexToPosition(i);
DataRow dataRow = dataTable.DefaultView[translatedIndex].Row;

HTH

Kent Boogaart
Replied On August 28, 2007 10:09 PM

Sorry Sarathi,

I saw your reply after posting mine above. Let me know if you need more info.

Sarathi D [Syncfusion]
Replied On August 29, 2007 04:53 PM

Hi Lcd,

Glad that you have solved the issue. Thank you for sharing the information with us.

Please let me know if you have any further queries.

Regards,
Sarathi

Kent Boogaart
Replied On August 29, 2007 08:44 PM

Hi Sarathi,

I'm interested to hear whether there are plans to fix RowIndexToListManagerPosition, or whether I'm just mistaken about its purpose. It seems to me it should facilitate exactly the functionality I was after, but doesn't.

Thanks

Sarathi D [Syncfusion]
Replied On September 10, 2007 09:01 PM

Hi Lcd,

Can you please create a direct trac incident in this regard since this is suspected to be a defect and we can discuss further on this issue.

Please specify the Forum Id in the subject line of the incident.

Regards,
Sarathi

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.

;