Hi all,
Is there any option to change the ultrawebgrid sorting from text to value for a particular column?
For ex: I have values 0,1 and in a column ,am showing one image if value=1 and value=0 =no images.
Please suggest a way to sort this column
Regards,
Jeena
Jeena,
If you use a template column you can set the value of the column and still have something else displayed in the column. Note that this may not work well with XML LoadOnDemand. Other than that you could try to manually sort a hidden column when rather than the column that has your image.
Let me know if you have any questions.
Hi,
My real issue was ,I am having a grid with one column as image.
The image column is created using a column value like this
Protected Sub DataGrid1_InitializeRow(sender As Object, e As Infragistics.WebUI.UltraWebGrid.RowEventArgs) Handles DataGrid1.InitializeRow If (e.Data("IsStandardIcon") = "1") Then e.Row.Cells(3).Text = "<center><img src='../Images/StandardS.png'></center>" e.Row.Cells(3).Value = "1" Else e.Row.Cells(3).Text = "" End If
END SUB.
When you are trying to change the text of the cell,its value also will change.,so the sorting of the column will not work.
Now I have modified the code as follows
Dim colIsStandardIcon As New UltraGridColumn("IsStandardIcon", "<center><img src='../Images/StandardS.png'></center>", ColumnType.CheckBox, Nothing) colIsStandardIcon.BaseColumnName = "IsStandardIcon" colIsStandardIcon.Width = Unit.Pixel(25) colIsStandardIcon.AllowUpdate = AllowUpdate.No Me.DataGrid1.DisplayLayout.Bands(0).Columns.Add(colIsStandardIcon)
Dim dtStandardExist As New DataTable dtStandardExist.Columns.Add("DisplayText") dtStandardExist.Columns.Add("Value") Dim drStandardExist As DataRow = dtStandardExist.NewRow drStandardExist("DisplayText") = "<center><img src='../Images/StandardS.png'></center>" drStandardExist("Value") = "1" dtStandardExist.Rows.Add(drStandardExist) Dim drStandardNotExist As DataRow = dtStandardExist.NewRow drStandardNotExist("DisplayText") = "." drStandardNotExist("Value") = "0" dtStandardExist.Rows.Add(drStandardNotExist) For Each dr As DataRow In ds.Tables("Knowledge").Rows 'If (dr("IsStandardIcon").ToString() = "0") Then ' Me.DataGrid1.DisplayLayout.Bands(0).Columns.FromKey("IsStandardIcon").ValueList.DataSource = dtStandardExist 'End If 'ElseIf (dr("IsStandardIcon").ToString() = "0") Then 'Me.DataGrid1.DisplayLayout.Bands(0).Columns.FromKey("IsStandardIcon").ValueList.DataSource = dtStandardExist Me.DataGrid1.DisplayLayout.Bands(0).Columns.FromKey("IsStandardIcon").ValueList.DisplayMember = "DisplayText" Me.DataGrid1.DisplayLayout.Bands(0).Columns.FromKey("IsStandardIcon").ValueList.ValueMember = "Value" Me.DataGrid1.DisplayLayout.Bands(0).Columns.FromKey("IsStandardIcon").ValueList.DataSourceID = "Value" Me.DataGrid1.DisplayLayout.Bands(0).Columns.FromKey("IsStandardIcon").ValueList.DataBind() Me.DataGrid1.Columns.FromKey("IsStandardIcon").Type = ColumnType.DropDownList Me.DataGrid1.DisplayLayout.AllowUpdateDefault = AllowUpdate.Yes Me.DataGrid1.DisplayLayout.CellClickActionDefault = CellClickAction.Edit Next
Now the sorting is working perfectly..if value=0 i don't want to display anything in the column
But if i change the line
drStandardNotExist("DisplayText") = "."
like this
drStandardNotExist("DisplayText") = " " the column will fill with 0,1 (No image will come)
Any fixes for this?
If all you specify is the value and the text is empty then it is expected to display the value. Using a TemplateColumn would allow you to net set any content to display and set a different value that could be used for sorting on the column. Is this an option for you?
Hi Alan,
Could you please paste a sample code ..My grid has other columns too.
I i wanted to make this column as a templatedone,i should change all columns,or i can change this column alone..Am a newbie in this controls.
You can do it on a single column:
http://help.infragistics.com/doc/ASPNET/2011.1/CLR4.0/?page=WebGrid_Using_Column_Templates.html
For examples with templates, look at the samples on the following knowledge base article and articles it links to:
http://devcenter.infragistics.com/Support/KnowledgeBaseArticle.aspx?ArticleID=4876
Let me know if you have any questions with this matter.