Hello .. any help with this is appreciated. I am using 8.2. I added a valuelist to a column in the designer but it was displaying the value instead of the text, so I removed it and used the following code from a knowledge base article. Still it is displaying the number instead of the letter until I click on it to edit.
Dim vList As New Infragistics.WebUI.UltraWebGrid.ValueList()gridApps.Columns(4).ValueList = vListvList.ValueListItems.Add(0, " ")vList.ValueListItems.Add(1, "R")vList.ValueListItems.Add(2, "T")gridApps.DisplayLayout.Bands(0).Columns(4).ValueList = vListgridApps.DisplayLayout.Bands(0).Columns(4).ValueList.DisplayStyle = Infragistics.WebUI.UltraWebGrid. ValueListDisplayStyle.DisplayText
Hello,
This code should work. I was wondering about the data type of the column. What kind of data is displayed in the column? When the cell goes into edit mode, then the text field of the ValueList is displayed in the dropdown. When one of the option from the dropdown is selected it overwrites the text presented in the cell. The AllowUpdate property for this column needs to be set to true in order to do this. Please include these following lines of code after populating the ValueList:
UltraWebGrid1.Columns(4).AllowUpdate = Infragistics.WebUI.UltraWebGrid.AllowUpdate.Yes
UltraWebGrid1.Columns(4).Type = Infragistics.WebUI.UltraWebGrid.ColumnType.DropDownList
UltraWebGrid1.Columns(4).ValueList = vList
Let me know if you get any issues with this.
Thanks
I put in the suggested lines, and I am still not getting the display text showing until you enter edit mode. Then you can see the text displayed in the dropdown. And the updates do work correctly. I have attached a sample project, I put the script to create the simple table I used in the web.config. I tried putting the code in various places, and now just have it in the pageload.
Doh, I had a netadv sample from another problem I was reporting. I'm attaching the sample I meant to put in the first time .. sorry. Anyway, I'm going to try the initializerow method. I just thought that the grid would display the text automatically if you had a valuelist.
This is odd .. I put the following code in the initializerow to just take care of the display myself. Looking at debug, the first row that went thru, the value of the cell was the displaytext, in other words the string ("R" or "T") so it got an error of course comparing string to byte, the datavalue of the valuelist. But the second row to come thru, the cell had the correct value (2 in this case, byte) .
Dim i As IntegerFor i = 0 To grid1.DisplayLayout.Bands(0). Columns(4).ValueList.ValueListItems.Count-1 If e.Row.Cells(4).Value = grid1.DisplayLayout.Bands(0).Columns(4). ValueList.ValueListItems(i).DataValue Then e.Row.Cells(4).Text = grid1.DisplayLayout.Bands(0).Columns(4). ValueList.ValueListItems(i).DisplayText End IfNext
I added similar lines in the initializerow in the sample app that I uploaded and discovered each row goes thru the initializerow event 2 times. First time the cell value is the byte datavalue and the cell text is the displaytext, but the second time the cell value and the displaytext are both set to the displaytext.
So for example, if I have a valuelist item with DataValue=1 and DisplayText = "A"
First Time: Cell.Value = 1 and Cell.Text = "A"Second Time: Cell.Value = "A" and Cell.Text = "A"
Dim i As IntegerFor i = 0 To grid1.DisplayLayout.Bands(0). Columns(2).ValueList.ValueListItems.Count - 1 If e.Row.Cells(2).Value = grid1.DisplayLayout. Bands(0).Columns(2).ValueList.ValueListItems(i).DataValue Then e.Row.Cells(2).Text = grid1.DisplayLayout.Bands(0). Columns(2).ValueList.ValueListItems(i).DisplayText End IfNext
Hi,
I'm wondering why the InitializeRow event is getting fired twice? I didn't get a chance to look at the second sample you've attached here. However, to work around the issue you are having with comparing the cell values, you can include a hidden column where the values (0,1,2 etc) are stored and depending on these values you can populate the visible column with text ('R','T' etc). The ValueList should be embedded to the visible column.
I'll give you my feedback on the code as soon as I get a chance.
I am joining this thread too late. But following is my approach which I generally use when I want to bind value list for any column.
I just populate a DataTable from my primary table of my value list reference column. Later I bind that table with value list of the column and set DisplayMember and ValueMember properties.
This is very simple and logical because we always need reference value from some primary data base table.
I have tested the sample with following code. The in actual program dt should be filled from primary table from database.
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim dt As DataTable
dt = New DataTable()
dt.Columns.Add("Byte", GetType(Byte))
dt.Columns.Add("Txt", GetType(String))
Dim dr As DataRow
dr = dt.NewRow()
dr(0) = 4
dr(1) = " "
dt.Rows.Add(dr)
dr(0) = 1
dr(1) = "A"
'Similarly add rows for B,C,D....
'dt should be filled with data from primary table
grid1.Columns(2).AllowUpdate = Infragistics.WebUI.UltraWebGrid.AllowUpdate.Yes
grid1.Columns(2).Type = Infragistics.WebUI.UltraWebGrid.ColumnType.DropDownList
grid1.Columns(2).ValueList.DataSource = dt
grid1.Columns(2).ValueList.DisplayMember = "Txt"
grid1.Columns(2).ValueList.ValueMember = "Byte"
grid1.Columns(2).ValueList.DataBind()
End Sub
Hi Folks,
Do you know if the ValueList feature is still available on the new version of WebDataGrid and WebHierarchicalDataGrid Controls (11.2.20112.2025)?
If not, what functionality has replaced it? Or how should a similar solution be implemented?
Thanks,
Victor
For future readers, the value display was not working because the grid thought the column type was String, bu that the Id type of the ValueList was integer...Making both types the same (Integer in this case) fixed up the issue.
That works pretty good .. thanks, I'm going to do that. I still think the other should work.