We set the valuelist of a column to an ultradropdown, and bind the data source of the ultradropdown via setdatabinding(). Each dropdown in each row in the grid will have the same list. If I try to plug a list on a given row (even the cell's valuelistresolved) it changes the list in the dropdown on each other row. How can I populate the dropdowns on different rows with different items?
If you set the ValueList property of a cell, it does not affect any other cell. If this is happening, then something else is going on in your code that is causing it.
Typically, if you are going to assign a ValueList to the cell, you would do so in the BeforeCellActivate or InitializeRow event of the grid - or maybe both. It depends on the behavior you want.
Thanks, but this was the answer I was afraid to hear - I'm really concerned about performance - filling drop down lists for each row instance, and multiple drop downs per row, especially if the drop down lists are large and the number of rows are large, which is frequent for us. Yikes! Is there a suggested strategy to follow with respect to obtaining good performance in such a situation?
Please confirm my understanding - if I set a drop down on the column's valuelist, I can access it via the column valuelist or the cell valuelistresolved, but the cell's valuelistresolved is really a reference to the column's valuelist. BUT, if I instead set a drop down on the cell's valuelist, then each cell's valuelistresolved will be a unique list?
Thanks a lot!
Yes, everything you wrote here is correct.
There are a couple of ways you could deal with the performance issue.
You probably don't have a completely different list for every cell. You probably have a small number of possibles lists. So what you could do is use the same ValueList for all the cells that need the same list. That way, you don't end up creating the same list twice. If it were my application, I would probably set up a sort've caching mechanism where I ask for the list inside the InitializeRow event of the grid and I either create a new list at that point, or re-use an existing list if there is one.
Another approach you could take is to use one list that contains all of the possible values for all possible cells and then just change the ColumnFilters on the UltraDropDown to limit the user to the valid choices for that row. This way you only create one list.
There's no 100% right way to do this. Personally, I would use the BeforeCellListDropDown event of the grid if you want to change the filter every time the user drops down the list within the grid.
Another option would be to use the Before/AfterRowActivate event. But using BeforeCellListDropdown is probably better, since the user might activate a row and never drop down the list.
Fixed like this ... I'm filtering the list on each BeforeDropDown
- it wasn't breaking into the BeforeDropDown before because the designer removed the event.-
But is this the "correct" way to do it ?
private void _ucTasks_BeforeDropDown(object sender, CancelEventArgs e) { //needed because the _ugStatus_InitializeRow is not entered again for the row, so it get's the latest ValueList from different ( incorrect ) row: _ucTasks.Rows.ColumnFilters["PhaseID"].ClearFilterConditions(); int phaseID = (Int32)(_ugStatus.ActiveRow.Cells["PhaseID"].Value); _ucTasks.Rows.ColumnFilters["PhaseID"].FilterConditions.Add(FilterComparisionOperator.Equals, phaseID); _ugStatus.ActiveCell.ValueList = _ucTasks; } private void _ugStatus_InitializeRow(object sender, Infragistics.Win.UltraWinGrid.InitializeRowEventArgs e) { //is just when entering the row for the first time: if (e.Row.Band.Key == "ProjectTasks") { int rusl = _ucTasks.Rows.Count; //Weird Fix! ... if this is not done, the FilterComparisionOperator will not work in the UltraCombo and will display the Red-Cross [Eiki] _ucTasks.Rows.ColumnFilters["PhaseID"].ClearFilterConditions(); int selectedPhase = 0; if( e.Row.Cells["PhaseID"].Value != null ) selectedPhase = (Int32)(e.Row.Cells["PhaseID"].Value); _ucTasks.Rows.ColumnFilters["PhaseID"].FilterConditions.Add(FilterComparisionOperator.Equals, selectedPhase); e.Row.Cells["TaskID"].ValueList = _ucTasks; } }
Just wanted to point out that the child #1 row is still open ( visible ) when I'm working on child #2 row ... e.g. I can see the whole Tree/Grid open ...
I need the filtering of the valueList to be applied everytime it's opened up I guess ?The problem is that that the Initlize_Row runs the FIRST time the row is initlized, and not again ...so the first ValueList will take on the same values as the next ValueList which is initialized. I'm just using one UltraCombo for this particular column in the grid, and just applying the FilterComparison on it ... but not working as I described above.-
You can also verify this very easily by putting this line at the top of the Initilize_Row of the Grid:e.Row.ExpandAll();
and then all the ValueLists ( on different levels in the grid ) will have the same values- it will take the values of the last ValueList filtering.-How would you correct this or implement differently ? I clearly need to load the ValueList for each column just ONCE and make it STAY like that, not taking the last ValueList each time a different parentID is sent to the DB to seek available_values
Please helprgd,EE.
Hi Mike!
I created a similar behaviour as you're descriping ...
_availableTasksBindingSource.DataSource = RecoveryPlanner.Business.
TaskList.GetAll(); I loaded a ValueList of 136 items and then I use the FilterConditions of the UltraCombo to filter down the available entries by which level I am on in the Grid.
then I do something like this:private void _ugStatus_InitializeRow(object sender, Infragistics.Win.UltraWinGrid.InitializeRowEventArgs e) { if (e.Row.Band.Key == "ProjectTasks") { int rusl = _ucTasks.Rows.Count; //Weird Fix! ... if this is not done, the FilterComparisionOperator will not work in the UltraCombo and will display the Red-Cross [Eiki] - A bug by Infragistics
_ucTasks.Rows.ColumnFilters["PhaseID"].ClearFilterConditions();
int selectedPhase = 0;
if( e.Row.Cells["PhaseID"].Value != null ) selectedPhase = (Int32)(e.Row.Cells["PhaseID"].Value);
_ucTasks.Rows.ColumnFilters["PhaseID"].FilterConditions.Add(FilterComparisionOperator.Equals, selectedPhase); e.Row.Cells["TaskID"].ValueList = _ucTasks; } }
This is all good and well ... BUTWhen I open up the first child the list is correct ( it takes it's parent ID as a parameter and filters by that value, e.g. parameter int val = 1 for example ) ...Then I open up the second child (which under a different parent than the first child ... e.g. parameter int val = 2 for example ) and it loads that list up just fine ... everything is correct so far.
BUT then I jump to the child 1 row and fire up the UltraCombo DropDown and now it has the values of parent int val = 2 !! e.g. it does not enter the _ugStatus_InitializeRow again ( UltraGrid's InitilizeRow ) because it already initilized that row when I FIRST opened up the parent1 ( to see children 1 ) so it's not Re-Initlize'ing it ... so it will use the last ValueList created!
Where would you do the filtering in this case ? I was thinking about like this ... but it never enters this code:private void _ucTasks_BeforeDropDown(object sender, CancelEventArgs e) { int phaseId = (Int32)(_ugStatus.Selected.Rows[0].Cells["PhaseID"].Value); _ucTasks.Rows.ColumnFilters["PhaseID"].FilterConditions.Add(FilterComparisionOperator.Equals, phaseId); }