Hi,
I am binding a valuelist to my ultrawingrid as shown in the attached sample. the value list items can change based on the value of the status column.
click the mouse on the cell on the 3rd column
1. when i change the value in the value list 1st row the cell updates properly
2. when i change the value in the value list 2nd row the cell updates properly
3. when i try to change the value in value list in 3rd row it changes the cell value of the 1st row.
similarly if we edit multiple rows.. all the previous edited rows get affected once we move the move to a new row
Please help me in resolving this.
thank you.
Changing the ValueList for the column will not work correctly, because when the grid paints a cell, it needs the ValueList to convert the DataValue from the cell into the matching DisplayText on the list - and if the list is not there, it cannot do it.
What you should do here is set the ValueList on the cell instead of on the column.
Or, you could check out this article which shows how to do this with a single list that uses filtering.
Creating a dropdown list in a grid cell whose list values are dependent on another cell - Windows Forms - Infragistics Community
By the way... your sample has some pretty strange code in it. For example, this line of code is going in circles:
UltraGrid1.ActiveCell.Column.Header.Column.ValueList = BuildStatusList(UltraGrid1.ActiveRow.Cells("Status").Value.ToString)
You are getting the Column property on the cell here, then getting the Header, and then going back to the column. These two objects are exactly the same:
UltraGrid1.ActiveCell.Column = UltraGrid1.ActiveCell.Column.Header.Column
Anyway, what you really should be doing is this:
UltraGrid1.ActiveCell.ValueList = BuildStatusList(UltraGrid1.ActiveRow.Cells("Status").Value.ToString)
Hi Mike,
Thanks for the reply and the suggestion.
I understand what you are saying. But if i bind the value list in the UltraGrid_IntializeLayout i will see the dropdown visible everytime the mouse hovers over any cell in status column. That is the reason i am setting cell activation to NoEdit in UltraGrid_IntializeLayout and then making it AllowEdit in UltraGrid1_MouseUp. my requirement was to show the dropdown only when the user clicks on the cell to change the status.
I have tried setting the value list on the Cell. Even then when i continously change the status on the cells on different rows, the previously edited cells are set with the value id's like 0,10,20..
I have also tried this using UltraGrid1_AfterCellUpdate instead of UltraGrid1_AfterCellListCloseUp but i am facing the same issue.
can you replicate this issue at your end? Please suggest
Thank you.
suneelsunkara said:I understand what you are saying. But if i bind the value list in the UltraGrid_IntializeLayout i will see the dropdown visible everytime the mouse hovers over any cell in status column. That is the reason i am setting cell activation to NoEdit in UltraGrid_IntializeLayout and then making it AllowEdit in UltraGrid1_MouseUp. my requirement was to show the dropdown only when the user clicks on the cell to change the status.
You only want the dropdown arrow to display after the user clicks on the cell and it goes into edit mode?
I don't see any way that that could work, because once the user clicks on the cell and makes a change, you must keep the ValueList attached to that cell to handle the translation from the DataValue to DisplayText. Otherwise, the text will be lost.
What I would do is attach the ValueList in the InitializeRow event and/or the BeforeCellActivate event.
suneelsunkara said:I have tried setting the value list on the Cell. Even then when i continously change the status on the cells on different rows, the previously edited cells are set with the value id's like 0,10,20..
If that's still happening, then something is wrong with your code. Perhaps you are not assigning the correct ValueList to the cell or perhaps it's getting removed, or maybe you are assigning the ValueList at the wrong time.
If you would like to post another sample that sets the ValueList property on the cell and is still haveing the same issue, I would be happy to take a look at it for you again.
I want the dropdown to be displayed only after the user clicks on the cell and then the cell will be in edit mode. I need this because if i bind the value list in the initialize_layout it displays the drop down when ever i do a mouse hover on the Status column on all the rows.
One more thing is my status can change dynamically based on the current status on the cell. So what i mean is my value list can have different list of items for each row. That is the reason i want to populate them when i click on the cell.
In the UltraGrid1_MouseUp event if i am currently setting the value list for the cell. and when the dropdown apprears and the user selects any value then i am handling it in the UltraGrid1_AfterCellListCloseUp by checking the e.Cell.EditorResolved.IsValid flag and then taking the e.Cell.EditorResolved.Value to validate if the selected value is a valid value list item.
In this case if i click the cell on the 1st, 2nd, 3rd row it works fine.. After if i go to the 1st row and click the cell the e.Cell.EditorResolved.IsValid flag is False and the cell value remains like 0,10.. and the drop down doesnt appear.
I think i am not able to find the right event to do this. Please help me on this. If possible can please fix this in the attached sample and let me know?
You code here doesn't make a lot of sense to me.
If you don't want the ValueList to be attached to the cell until the user tries to edit that cell, then that's fine. But you should use the BeforeEnterMode event, not MouseUp.
The way you have this set up now, is that if a cell in the Status column happens to be active and I click anywhere in the grid - or even try to click off of the grid, the list drops down and you cannot escape it.
Also, the cell enters edit mode on the MouseDown, but the MouseUp. So when you click the cell, it goes into edit mode and then when you release the mouse, you are changing the ValueList while the cell is already in the middle of an edit. So my guess is that this is the real reason this is not working.
I tried moving your code from MouseUp into the BeforeEnterEditMode event, but of course, this does not work, because you are not allowing editing on the Status column.
I also tried MouseDown, but it looks like the cell enters edit mode before the MouseDown event is called, so this does not work either.
I tried a bunch of other methods to get this to work and I cannot get it to work the way you want. There's probably some kind of caching going on here in the grid cell where it's holding on to the selected ValueList row.
I think the only way you can do what you want here is to use the UltraDropDown control and filter the items. That way you don't have to create a new list for each cell and you can keep the entire list all the time and simply filter out the items you don't want the user to be able to select.
Hi Ravindra,
There no difference between a bound column and an unbound column as far as ValueLists go. My best guess with such limited information is that your bound field is probably ReadOnly. Therefore the cell is read-only, and therefore, you cannot show a dropdown, since dropdowns are for editing the value of a cell. Are you able to edit the cell? Can you go into edit mode and get a blinking caret? Can you type into it?
I have an Entity Accounts that has a Foriegn Key Contraints on CalcType Entity.
When I bind the UltraGrid to the this Entity Accounts. The UltraGrid's Column 'CalcType' is not getting displayed as DropDownList even though I am specifying the Style and providing the ValueList to the Column.
UltraGrid_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e)
{
e.Layout.Bands[0].Columns["CalcType"].Style = ColumnStyle.DropDownList;
e.Layout.Bands[0].Columns["CalcType"].ValueList = // Code to get the valuelist ;
}
However, for an unbound entity it displays the Dropdown correctly.
if (!e.Layout.Bands[0].Columns.Exists("CalcTypeEdit"))
e.Layout.Bands[0].Columns.Add("CalcTypeEdit");
e.Layout.Bands[0].Columns["CalcTypeEdit"].ValueList = // Code to get the valuelist ;
The above works. Please suggest a work around or solution (in case I am not using it correctly).
Regards,
Ravindra Mohan
Thank you Mike. I will try to implement the solution using a UltraDropDown control.